2013-07-03 40 views
0

我有一個導航屬性public virtual IUser<int> CreateBy { get; set; }導航屬性可以是泛型類型?

當我嘗試添加遷移Add-Migration InitialMigration,會出現以下錯誤:

的導航屬性「CreateBy」不在類型「帕蘇」聲明的屬性。驗證它是否未明確從模型中排除,並且它是有效的導航屬性。

我喜歡的類型Passo

public class Passo : EntityNome, IAuditable 
{ 
    public virtual int? Ordem { get; set; } 
    public virtual Passo ProximoPasso { get; set; } 
    public virtual ICollection<User> Responsaveis { get; protected set; } 
    public virtual IList<CheckListItemTemplate> CheckListItens { get; protected set; } 

    public virtual DateTime CreateAt { get; protected internal set; } 
    public virtual IUser<int> CreateBy { get; set; } 
    public virtual DateTime? UpdateAt { get; protected set; } 
    public virtual IUser<int> UpdateBy { get; set; } 
} 

回答

0

IUSER爲int的集合?你不能導航到基元。

它需要是上下文中聲明的表的集合或引用。

public DbSet<int> Integers { get; set; }// you cant declare table of integers ??? 

// futhermore EF需要公共的get/set,這將被忽略 公共虛擬的ICollection Responsaveis {獲得;保護組; }

請參閱導航概念 http://msdn.microsoft.com/en-us/data/jj713564.aspx