Invalid object name 'dbo.AspNetUsers'

梦想与她 提交于 2019-12-22 12:37:56

问题


I have an MVC5 application using Entity Framework 6.1 and Asp.Net Identity 2 and have data migrations enabled. I have used sample code from other answers on StackExchange to seed the Role and User tables. My application data context is based on IdentityDbContext. On issuing an update-database command, my database is created and populated with the following tables:

My app launches OK, but when I try to log in using the seeded user (or any user for that matter), I get the following error:

How can I get SignInManager to reference the IdentityUsers table instead of AspNetUsers?


回答1:


You can set custom names in OnModelCreating

protected override void OnModelCreating(DbModelBuilder mb)
{
    base.OnModelCreating(mb);

    mb.Entity<User>().ToTable("IdentityUsers");
   ...
}


来源:https://stackoverflow.com/questions/27358034/invalid-object-name-dbo-aspnetusers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!