asp.net mvc - asp identity with int as TKey - UserId not found exception -


i have implemented custom userstore , identityuser. have changed code uses int key type.

the problem leave key generation database autoincrement field. now, on register, user saved db framework doesnt have id (its int default 0) since doesnt read return values db. (db did create new id autoincrement , saved framework dont have it)

am doing wrong?

questions:

  1. are suposed additional roundtrip db (find username, example) id?

  2. should we, on register, create 1 dummy record id , update real data?

all of feels dirty.

has solved problem?

update: adding code it

my identityuser:

public class identityuser : iuser<int> {     public int id { get; set; }     public string username { get; set; }     public string passwordhash { get; set; }     public string securitystamp { get; set; }     public string email { get; set; }     public string phonenumber { get; set; }     public bool isemailconfirmed { get; set; }     public bool isphonenumberconfirmed { get; set; }     public int accessfailedcount { get; set; }     public bool lockoutenabled { get; set; }     public datetime? lockoutenddate { get; set; }     public bool twofactorauthenabled { get; set; }  public identityuser()     {         //this.claims = new list<claim>();         //this.logins = new list<userlogininfo>();     }      public identityuser(int userid, string username)         : this()     {         this.id = userid;         this.username = username;     } } 

my userstore, createnew method:

public task createasync(tuser user)         {             if (user == null)             {                 throw new argumentnullexception("user", "user must not null.");             }              _userdb.insert(user);              return task.fromresult(0);         } 

so, bit more of description:

1) user clicks on register

2) gets prompted register form

3) submits email, password, confirmpassword

4) record gets created in db

5) problem comes here, in account/register:

var result = await usermanager.createasync(user, model.password);                 if (result.succeeded)                 {                      await signinmanager.signinasync(user, ispersistent:false, rememberbrowser:false); 

user parameter in signinasync not have id (it has int default value of 0) because, obviously, didn't value of id sql db assigned through auto-increment.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -