基础建设中不System.Data.Entity的存在 [英] Infrastucture does not exist in System.Data.Entity
问题描述
我想创建实体框架MVC项目。
我有解决方案3项目
I am trying to create MVC project with Entity Framework. I have 3 Projects in Solution
- SerialTracker.Common
- SerialTracker.Model
- SerialTracker.Web
通用和模型编译像库,所以网站在使用它们。
模型还利用通用。
Common and Model are compiled like library, so Web is using them. Model is also using Common.
我的万阿英,蒋达清是在这里:
My probelm is here:
从型号的.edmx * ==> * .Context.tt ==>生成加入WTO要求自动生成* .Context.cs:
Model generate from *.edmx ==> *.Context.tt ==> whitch auto generates *.Context.cs:
namespace SerialTracker.Model
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class SerialTrackerEntities : DbContext
{
public SerialTrackerEntities()
: base("name=SerialTrackerEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<Role> Role { get; set; }
public DbSet<User> User { get; set; }
}
}
我有错误,基础建设不存在System.Data.Entity的。我尝试添加一些参考,但我认为这个问题是在另一个地方。
I have error, that Infrastucture does not exist in System.Data.Entity. I tried adding some References, but i think the problem is in another place.
//编辑:
我reinstaled的NuGet包这个项目,但现在我有错误,并且不存在
// I reinstaled NuGet package for this project, but now i have error and doesn't exist
对不起,我英文不好。
推荐答案
所以我̶m̶a̶n̶u̶a̶l̶y̶添加的文件̶S̶e̶r̶i̶a̶l̶T̶r̶a̶c̶k̶e̶r̶.̶t̶t̶到̶S̶e̶r̶i̶a̶l̶T̶r̶a̶c̶k̶e̶r̶.̶e̶d̶m̶x̶.̶
这个文件我复制从另一个̶p̶r̶o̶j̶e̶c̶t̶.̶
现在是项目产生的实体̶R̶i̶g̶h̶t̶.̶
S̶o̶ ̶I̶ ̶m̶a̶n̶u̶a̶l̶y̶ ̶a̶d̶d̶e̶d̶ ̶f̶i̶l̶e̶ ̶S̶e̶r̶i̶a̶l̶T̶r̶a̶c̶k̶e̶r̶.̶t̶t̶ ̶t̶o̶ ̶S̶e̶r̶i̶a̶l̶T̶r̶a̶c̶k̶e̶r̶.̶e̶d̶m̶x̶.̶
T̶h̶i̶s̶ ̶f̶i̶l̶e̶ ̶I̶ ̶c̶o̶p̶i̶e̶d̶ ̶f̶r̶o̶m̶ ̶a̶n̶o̶t̶h̶e̶r̶ ̶p̶r̶o̶j̶e̶c̶t̶.̶
N̶o̶w̶ ̶i̶s̶ ̶p̶r̶o̶j̶e̶c̶t̶ ̶g̶e̶n̶e̶r̶a̶t̶e̶ ̶e̶n̶t̶i̶t̶i̶e̶s̶ ̶R̶i̶g̶h̶t̶.̶
修改(2014年4月29日):
更新的答案:
您可以删除文件* .TT和
重新创建
添加 - >新建项目 - > EF 5.x的DbContextGenerator(或EF 6.x中...)
EDIT (04-29-2014):
Renewed answer:
You can delete file *.tt and recreate it with
Add -> New Item -> EF 5.x DbContextGenerator (or EF 6.x ...)
这篇关于基础建设中不System.Data.Entity的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!