【发布时间】:2009-05-27 19:55:34
【问题描述】:
我只是想先使用自我跟踪 POCO 方法做一些广泛的模型。但是,我没有让它按我的意愿工作。让我们来个博客。每个博客都有一组条目,每个条目都有一组评论。不幸的是,以下模型对我不起作用。 alt text http://blog.zoolutions.se/issue.png
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:架构 指定无效。错误: CLR 类型到 EDM 类型的映射是 模棱两可,因为有多种 CLR 类型 匹配 EDM 类型“条目”。之前 发现 CLR 类型 'Entry',新发现 CLR 类型 '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.ConditionalWeakTable2+Entry'。
有什么线索吗?我无法理解该错误消息...
【问题讨论】:
标签: entity-framework