I have successfully linked aspnetusers table to my custom users table as one-to-one relationship. Now when i go to register all information is successfully added to both tables except one thing - Id.
My pk userId in users table is an AutoIncrement key and i wish to add the same value in the id field of aspnetUsers table. I think i will have to override createAsync or do i remove from SignInAsync
await user.GenerateUserIdentityAsync(UserManager)
Inside AccountController Register method, I have
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var geUser = new User { Password = model.Password, Username = model.Email, AccessLevel = "0003", LoggedIn = false, Active = true, AllowOffline = false, LastSettingsRefreshed = DateTime.Now };
var user = new ApplicationUser() { UserName = model.Email, Email = model.Email, user = geUser};
IdentityResult result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInAsync(user, isPersistent: false);
return RedirectToAction("Index", "Home");
}
else
{
AddErrors(result);
}
}
return View(model);
}
My Data Tables: ASPNetUSers and Users respectively:
I want to enter 43 instead of 0 in aspnetusers table
UPDATE
On research i see that it has something to do with DatabaseGeneratedOption but exactly what and on which table should i do "DatabaseGeneratedOption.None"?