以下是我似乎无法修复的错误:
Schema specified is not valid. Errors:
The relationship 'Repository.ForumCategory' was not loaded because the type 'RepositoryModel.ForumCategories' is not available.这是我的ForumCategory类:
public class ForumCategory
{
//
// Scalar Properties
public int Id { get; set; }
public string Name { get; set; }
public int Order { get; set; }
public virtual ICollection<Forum> Forums { get; set; }
}这是我的论坛类:
public class Forum
{
//
// Scalar Properties
public int Id { get; set; }
public int CategoryId { get; set; }
public string Icon { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int ThreadCount { get; set; }
public int PostCount { get; set; }
public virtual Nullable<DateTime> LastPostDate { get; set; }
public int Order { get; set; }
//
// Navigation Properties
public virtual ForumCategory Category { get; set; }
}这是我的RepositoryContext:
public class RepositoryContext : ObjectContext
{
private IObjectSet<ForumCategory> _forumCategories;
private IObjectSet<Forum> _forums;
public SHRepositoryContext()
: base("name=Repository", "Repository")
{
ContextOptions.LazyLoadingEnabled = true;
_forumCategories = CreateObjectSet<ForumCategory>();
_forums = CreateObjectSet<Forum>();
}
public IObjectSet<ForumCategory> ForumCategories
{
get { return _forumCategories; }
}
public IObjectSet<Forum> Forums
{
get { return _forums; }
}
}这是我的实体模型:

真的需要帮助,我读了一些人的回答,但似乎没有一个是相关的=\
发布于 2012-07-24 20:41:47
问题是:我在模型中有一个关联覆盖了我的ForumCategory名称。解决方案是:我将关联重命名为Forum_Category,并将实体重命名为ForumCategory。这解决了我的问题!
https://stackoverflow.com/questions/9740663
复制相似问题