使用ApplicationUser的多对多EF核心

时间:2016-08-13 19:54:28

标签: entity-framework entity-framework-core

我正在尝试在ApplicationUser和Reserve之间创建多对多关系。

public class ApplicationUser : IdentityUser
{
    public ApplicationUser()
    {
        this.Reserves = new HashSet<Reserve>();
    }
    public bool IsProfessional { get; set; } 

    public virtual ICollection<Reserve> Reserves { get; set; }
}

public class Reserve
{

    public Reserve()
    {
        this.Usuarios = new HashSet<ApplicationUser>();
    }
    public int ID { get; set; }
    public string Begin { get; set; }
    public string End { get; set; }
    public string Date { get; set; }
    public string Status { get; set; } //free , reserved, confirmed, canceled
    public DateTime LastUpdate { get; set; }

    public virtual ICollection<ApplicationUser> Usuarios { get; set; }
}

但我无法添加迁移

PM> Add-Migration user-reserve-relationship
Unable to determine the relationship represented by navigation property 'ApplicationUser.Reserves' of type 'ICollection<Reserve>'. Either manually configure the relationship, or ignore this property from the model. 

无论如何,相同的关系适用于其他实体但不适用于ApplicationUser。

我可以使用ApplicationUser多对多吗?

1 个答案:

答案 0 :(得分:1)

我在ef核心中找到了以下内容: 尚不支持没有实体类来表示连接表的多对多关系。 所以我的问题已经结束了。