1
这是我的错误,我似乎无法修复:MVC 4实体框架4 POCO:指定的架构是无效
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; }
}
}
这是我的实体模型:
真的需要帮助,已经从人们读了几个答案,但没有似乎是相关= \
我已经修复了我自己的问题呵呵! 问题是: 我有一个关联覆盖模型中我的ForumCategory的名称。 解决方案是: 我将关联重命名为Forum_Category并将实体重命名为ForumCategory。 这解决了我的问题! – 2012-03-16 16:13:25
通常的做法是发布自己的答案作为回答并接受它(将问题标记为已解决)。 – 2012-03-16 17:04:39