Frameworks MVC 4实体框架4 POCO:指定的架构无效
这些是我的错误,我似乎无法修复:Frameworks MVC 4实体框架4 POCO:指定的架构无效,frameworks,schema,entity,asp.net-mvc-4,Frameworks,Schema,Entity,Asp.net Mvc 4,这些是我的错误,我似乎无法修复: 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 { // //
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; }
}
公共类ForumCategory
{
//
//标量性质
公共int Id{get;set;}
公共字符串名称{get;set;}
公共整数顺序{get;set;}
公共虚拟ICollection论坛{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; }
}
公共课堂论坛
{
//
//标量性质
公共int Id{get;set;}
public int CategoryId{get;set;}
公共字符串图标{get;set;}
公共字符串名称{get;set;}
公共字符串说明{get;set;}
public int ThreadCount{get;set;}
公共整数后计数{get;set;}
公共虚拟可空LastPostDate{get;set;}
公共整数顺序{get;set;}
//
//导航属性
公共虚拟论坛类别{get;set;}
}
这是我的位置上下文:
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; }
}
}
公共类RepositoryContext:ObjectContext
{
私有IObjectSet _forumCategories;
私人IObjectSet论坛;
公共存储上下文()
:base(“名称=存储库”、“存储库”)
{
ContextOptions.LazyLoadingEnabled=true;
_forumCategories=CreateObjectSet();
_forums=CreateObjectSet();
}
用于umcategories的公共对象集
{
获取{return\u forumCategories;}
}
公共IObjectSet论坛
{
获取{return\u论坛;}
}
}
这是我的实体模型:
真的需要帮助,从人们那里读过一些答案,但似乎没有一个是相关的=\问题是:我有一个关联覆盖了模型中ForumCategory的名称。解决方案是:我将协会重命名为Forum_类别,并将实体重命名为ForumCategory。这解决了我的问题 问题是:我有一个关联覆盖了模型中ForumCategory的名称。解决方案是:我将协会重命名为Forum_类别,并将实体重命名为ForumCategory。这解决了我的问题 我已经解决了我自己的问题,呵呵!问题是:我有一个关联覆盖了模型中ForumCategory的名称。解决方案是:我将协会重命名为Forum_类别,并将实体重命名为ForumCategory。这解决了我的问题!通常的做法是把你自己的答案贴出来作为答案并接受它(把问题标记为已解决)。我已经修正了我自己的问题呵呵!问题是:我有一个关联覆盖了模型中ForumCategory的名称。解决方案是:我将协会重命名为Forum_类别,并将实体重命名为ForumCategory。这解决了我的问题!通常的做法是将自己的答案作为答案发布并接受(将问题标记为已解决)。