我只是想首先使用自我跟蹤POCO方法做一些廣泛的模型。然而,我並沒有按照我的意願去工作。我們開個博客吧。每個博客都有一組條目,每個條目都有一組評論。不幸的是,下面的模型不適合我。 alt text http://blog.zoolutions.se/issue.pngEF4 - POCO問題
的POCO類實現如下所示:
public class Blog
{
public bool Id { get; private set; }
public string Title { get; set; }
public bool AllowComments { get; set; }
public User User { get; set; }
public IList<Entry> Entries { get; set; }
}
public abstract class Post
{
public virtual int Id { get; set; }
public virtual string Header { get; set; }
public virtual string Text { get; set; }
public virtual DateTime CreatedAt { get; set; }
public virtual int UserId { get; set; }
}
public class Entry : Post
{
public Blog Blog { get; set; }
public IList<Comment> Comments { get; set; }
}
public class Comment : Post
{
public Entry Entry { get; set; }
}
這給了我一個很奇怪的錯誤:
System.Data.MetadataException: Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Entry'. Previously found CLR type 'Entry', newly found CLR type 'System.Collections.Generic.Dictionary
2+Entry'. The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Entry'. Previously found CLR type 'Entry', newly found CLR type 'System.Runtime.CompilerServices.ConditionalWeakTable
2+Entry'.
任何線索?我無法圍繞該錯誤消息打包我的頭......
感謝Alex,我將它改爲了BlogEntry,但是我發現有一些我發現我已經將Blog的Id字段設置爲bool以及:)我遇到了一些其他問題,但它們更容易處理。 – mhenrixon 2009-05-28 09:42:40