无效的对象名称"dbo.AspNetUsers" [英] Invalid object name 'dbo.AspNetUsers'

查看:350
本文介绍了无效的对象名称"dbo.AspNetUsers"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Entity Framework 6.1和Asp.Net Identity 2的MVC5应用程序,并启用了数据迁移.我使用了StackExchange上其他答案的示例代码来播种Role和User表.我的应用程序数据上下文基于IdentityDbContext. 发出update-database命令时,将创建我的数据库,并用以下表格填充该数据库:

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:

如何让SignInManager引用IdentityUsers表而不是AspNetUsers?

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

推荐答案

您可以在OnModelCreating中设置自定义名称

You can set custom names in OnModelCreating

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

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

这篇关于无效的对象名称"dbo.AspNetUsers"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆