C# 尝试连接ApplicationUser时没有密钥

C# 尝试连接ApplicationUser时没有密钥,c#,asp.net-mvc,entity-framework,asp.net-identity,C#,Asp.net Mvc,Entity Framework,Asp.net Identity,我在MVC5项目中使用VS 2015和最新版本的ASP.NET Identity 2.2.1 我有一个简单的模型: public class Student { public int ID { get; set; } public string Name { get; set; } public ApplicationUser SomeUser { get; set; } } 基本上,与ApplicationUser的1对1关系。以及通常的上下文 public clas

我在MVC5项目中使用VS 2015和最新版本的ASP.NET Identity 2.2.1

我有一个简单的模型:

public class Student
{
    public int ID { get; set; }
    public string Name { get; set; }
    public ApplicationUser SomeUser { get; set; }
}
基本上,与
ApplicationUser
的1对1关系。以及通常的上下文

public class Db : DbContext
{
    public DbSet<Student> Students { get; set; }
}
如果我第一次启动应用程序(并且创建了数据库表),则在键入
启用迁移时会发生此错误

我一直在阅读如何解决这个问题,但是,现在它不仅不能解决问题,而且当我点击新用户的“注册”或“登录”时,我得到:

ApplicationUser_Logins_Target: : Multiplicity is not valid in Role 'ApplicationUser_Logins_Target' in relationship 'ApplicationUser_Logins'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be '1'.
我还尝试只添加
base.OnModelCreating(modelBuilder)
ApplicationDbContext
中,如所建议,但也没有发生任何事情

我不知道该怎么办,几乎尝试了所有类似问题的解决方案。也许身份源代码发生了一些变化,不再有效


基本上,我试图做到的是:我想要连接,这样一个应用程序用户就有很多学生。我已经试着测试过了,所以我给
Student
添加了一个简单的关系作为开始,没有什么特别之处。因此,了解这一点后,如果有任何值得采取的替代方法通过一对多或一对一将注册用户连接到自定义模型,请告诉我。

您的Db继承自DbContext而非IdentityDbContext您的Db继承自DbContext而非IdentityDbContext
ApplicationUser_Logins_Target: : Multiplicity is not valid in Role 'ApplicationUser_Logins_Target' in relationship 'ApplicationUser_Logins'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be '1'.