【发布时间】:2018-01-15 19:28:30
【问题描述】:
我有一个existing application,我正在将它重写为带有 ReactJS 前端的 .NET Core API。我还在 API 端,遇到了问题。
代码
我有一个BbUser.cs 实体类,代码如下:
public class BbUser : IdentityUser
{
public int Points { get; set; } = 0;
public string DisplayUsername { get; set; }
}
我还有一个Artist.cs 实体类:
public class Artist
{
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string FirstName { get; set; }
[MaxLength(50)]
public string LastName { get; set; }
[MaxLength(100)]
public string UrlFriendly { get; set; }
public string ImageUrl { get; set; }
public bool IsVerified { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime ModifiedOn { get; set; }
public ICollection<Lyric> Lyrics { get; set; } = new List<Lyric>();
public string UserId { get; set; }
public BbUser User { get; set; }
}
我需要BbUser 和Artist 之间的一对多关系。一个用户可以提交许多艺术家和歌词...等。真的很简单。
问题
应用程序构建良好,但是当我尝试通过点击需要访问数据库的控制器来运行它时,我收到以下错误:
实体类型“IdentityUserLogin”需要定义一个主键。
我在使用常规 EF Code First(不是核心)和 the fix for that 时遇到了这个问题,在这里不起作用。
【问题讨论】:
标签: c# asp.net-core entity-framework-core