我ASP.NET Core Identity与Entity Framework Coreon一起使用.NET 5,使用带有 postgresql 数据库的代码优先方法。
我正在尝试像这样扩展身份类
public class User : IdentityUser<int>
{
public ICollection<UserLogin> Logins { get; set; }
}
public class UserLogin : IdentityUserLogin<int>
{
public User User { get; set; }
}
public sealed class AppDbContext : IdentityDbContext<User, Role, int, UserClaim,UserRole, UserLogin, RoleClaim, UserToken>
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行迁移时,它生成的表看起来像这样 -
请注意,UserId1已经创建了一个额外的列。
我希望它能够识别UserLogin.User导航Id应该与IdentityUserLogin.UserId属性相对应(根据 MS 在此处制定的约定:https : …
c# entity-framework-core asp.net-core-identity entity-framework-core-migrations .net-5