2016-08-13 130 views
-1

我正嘗試在ApplicationUser和Reserve之間創建一個多對多的關係。ApplicationUser多對多EF核心

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 multi-to-many嗎?

回答

1

我在ef核心中發現了以下內容: 尚未支持沒有實體類來表示連接表的多對多關係。 所以我的問題是關閉的。