Using custom user instead of ASP.NET IdentityUser -


i'm new on asp.net identity , trying customize identity provided while creating new mvc project.

asp.net identity automatically creates few tables handle authentication , authorization itself.

my main goal create users table others. i've tried following code prevent creating these tables:

protected override void onmodelcreating(dbmodelbuilder modelbuilder)     {         base.onmodelcreating(modelbuilder);         modelbuilder.ignore<identityuserrole>();         modelbuilder.ignore<identityuserclaim>();         modelbuilder.ignore<identityrole>();     } 

when want create user, following error returning:

the navigation property 'roles' not declared property on type 'applicationuser'. verify has not been explicitly excluded model , valid navigation property.

i found built-in identity user has following structure:

identityuser<string, identityuserlogin, identityuserrole, identityuserclaim>, iuser, iuser<string> 

what need creating custom identityuser not contains role, claim, etc. want table 'users' when run project.

any possibility create own identityuser or customize built-in one? or suggestion create 'users' table , work it?

many in advice.

this did in order solution:

  • i removed base.onmodelcreating
  • then added ignore in order.

    //base.onmodelcreating(modelbuilder); modelbuilder.entity<identityuser>().totable("user"); modelbuilder.entity<identityuser>().totable("user").ignore(p => p.roles); modelbuilder.ignore<identityuserrole>(); modelbuilder.ignore<identityuserlogin>(); modelbuilder.ignore<identityuserclaim>(); modelbuilder.ignore<identityrole>(); 

doing got final error said: not drop object 'dbo.role' because referenced foreign key constraint.

for changed migration moving droptable("dbo.role"). know hack, did not find out how ef migrations move droptables sentences right order.

richard


Comments