I'm trying to modify the orrible and insane tables names in example from AspNetUsers to Users.
My project is a WebForm WebSite Project. I'm using Visual Studio 2012, Entity Framework 6 and Framework 4.5. I've setup the entire Identity stuff, and everything is working fine.
Now I need to change tables names. If I put only the following code:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder); // This needs to go before the other rules!
modelBuilder.Entity<IdentityUser>().ToTable("Users");
modelBuilder.Entity<IdentityRole>().ToTable("Roles");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRoles");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogins");
modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaims");
}
in the ApplicationDbContext class, it's not executed, and if I try to change manually the table names I get the error:
Invalid object name 'dbo.AspNetUsers'
So following some suggestions I try to run enable-migrations Add-Migration and Update-Database commands, but from I get on the very first one the following error:
PM> enable-migrations -verbose
Using StartUp project 'MyProjectName'. Using NuGet project 'MyProjectName'. System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Server stack trace: at EnvDTE.Properties.Item(Object index) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at EnvDTE.Properties.Item(Object index) at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName) at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory) at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName) at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Please give me some directions as I don't know where to put my hands anymore. Thanks