【问题标题】:Fluent API and One to OneFluent API 和一对一
【发布时间】:2017-08-12 11:50:09
【问题描述】:

我正在尝试将 ApplicationRole (IdentityRole) 与父角色相关联,因为它是角色的类型。我想更好地理解 Fluent API 以完成此操作。

public class ApplicationRole : IdentityRole
{
    [StringLength(128)]
    [DisplayName("Based On Role")]
    public string BasedOnRoleId { get; set; }

    [ForeignKey("BasedOnRoleId")]
    public virtual ApplicationRole BasedOnRole { get; set; }
}

我目前有这样的东西不起作用...当然:

modelBuilder.Entity<ApplicationRole>()
                .HasKey(e => e.BasedOnRoleId)
                .HasRequired(e => e.BasedOnRole)
                .WithOptional(e => e.??)

【问题讨论】:

    标签: c# nhibernate entity-framework-6 asp.net-identity fluent


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多