我正在尝试在import pandas as pd
columns = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
df['count'] = df[columns].ne(0).sum(axis=1)
和AspNetUsers
之间建立关联。
“我的用户”表的定义如下:
Users
这是我的public class User
{
public long UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Contact { get; set; }
public string Address { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Role { get; set; }
public string Token { get; set; }
public List<Client> Clients { get; set; }
public string IdentityUserId { get; set; }
public IdentityUser IdentityUser { get; set; }
}
班:
DbContext
当我尝试在用户表中添加public class ApplicationDbContext : IdentityDbContext<IdentityUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public ApplicationDbContext()
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
..........................
}
属性的情况下添加新迁移时,出现以下错误:IdentityUser
。如果您打算使用无钥匙实体类型,请调用The entity type 'IdentityUserLogin' requires a primary key to be defined
。
我在其他项目中用相同的方式定义了关系,但没有收到此错误,并且我的users表链接到HasNoKey()
表。
我尝试了所有解决方案,其中大多数告诉您添加
AspNetUsers
转到我已经完成的base.OnModelCreating(modelBuilder);
函数,但仍然出现此错误。
我将ASP.NET Core 3.1与Entity Framework Core 3.1.5结合使用。
有人可以指出我在这里做错了什么吗?我还尝试从OnModelCreating
类继承我的Users
类,但仍然收到此错误。
感谢您的帮助。