c# - Trying to change the names of Asp.net Identity tables MVC5 -
i want alter default names of ap.net identity tables. have few questions in mind
1) possible if tables created , have data
2) can alter names of table , maintain info is
i have tried code:
protected override void onmodelcreating(system.data.entity.dbmodelbuilder modelbuilder) { base.onmodelcreating(modelbuilder); modelbuilder.entity<identityuser>().totable("myusers").property(p => p.id).hascolumnname("userid"); modelbuilder.entity<applicationuser>().totable("myusers").property(p => p.id).hascolumnname("userid"); modelbuilder.entity<identityuserrole>().totable("myuserroles"); modelbuilder.entity<identityuserlogin>().totable("myuserlogins"); modelbuilder.entity<identityuserclaim>().totable("myuserclaims"); modelbuilder.entity<identityrole>().totable("myroles"); } but throws me model backing context has changed error
the model backing 'applicationdbcontext' context has changed since database created. consider using code first migrations update database
you might want disable initializers. turned off prefer maintain database , code. e.g.
database.setinitializer<entities>( null ); you maintain model names if want , specify table name explicitly in model, e.g:
[table( "newtablename" )] internal class oldtablename { .... } c# asp.net-mvc-5 asp.net-identity
No comments:
Post a Comment