gpt4 book ai didi

c# - System.Data.Entity 中不存在基础结构

转载 作者:太空宇宙 更新时间:2023-11-03 16:20:49 25 4
gpt4 key购买 nike

我正在尝试使用 Entity Framework 创建 MVC 项目。我在解决方案中有 3 个项目

  • SerialTracker.Common
  • SerialTracker.Model
  • SerialTracker.Web

Common 和 Model 像库一样被编译,所以 Web 正在使用它们。模型也使用 Common。

我的问题在这里:

模型从 *.edmx 生成 ==> *.Context.tt ==> 自动生成 *.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 中不存在 Infrastucture。我尝试添加一些引用,但我认为问题出在另一个地方。

//编辑:我为这个项目重新安装了 NuGet 包,但现在我有错误并且不存在

抱歉我的英语不好。

最佳答案

s̶o̶̶̶̶̶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 ...)

关于c# - System.Data.Entity 中不存在基础结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13969642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com