解决:有一个错误产生“..Context”。尝试重建项目 [英] Resolved: There was an error generating '..Context'. Try rebuilding your project
问题描述
我学习插入,更新,从
https://www.youtube.com/watch?v=8f4P8U1a2TI
我添加新的实体框架
而增加新的控制器之后。
I add new Entity Framework and after that adding new Controller.
这是我的设置添加新控制器
here is my Setting for adding new Controller
当我保存添加控制器。错误出现。
when I save adding Controller . Error Comes ..
有一个错误发生
MvcApplication1.Models.EmployeeContext。尝试重建项目。
There was an error generating 'MvcApplication1.Models.EmployeeContext'. Try rebuilding your project.
EmployeeContext.cs
EmployeeContext.cs
public class EmployeeContext :DbContext
{
public DbSet<Employee> Employees { get; set; }
}
(Employee类是单独的组件)
(Employee class is in seperate Assembly)
解决方案我尝试:
- Cannot add controller in ASP.NET MVC project
它说,在造成的DbContext问题的一些特殊的构造......我没有任何
it says some special constructor in dbcontext caused problem... i dont have any
- 卸载并重新安装从实体框架的NuGet几次
3.Database.SetInitializer()摆在Application_Start方法中的Global.asax.cs中
3.Database.SetInitializer() placed in Application_Start method in Global.asax.cs
什么是错?请建议...
whats Wrong ? please suggest ...
推荐答案
确定,已解决。这里我做了什么
OK , Resolved .. Here what i did
-
我去掉模型类,上下文类和..这是手动创建的添加,删除,保存操作。实体框架自动生成这些事情。这样的矛盾是存在的......
I removed Model Class , Context Class and add , delete , save operations ..which were manually created . Entity Framework Auto Generates these things . so the conflict was occuring...
同时增加了新的控制器..In DataContext类科..Connectionstring名称应填写这是由自动实体框架生成。我被灌不正确的事情
while adding New controller ..In DataContext Class Section ..Connectionstring name should be filled which is Auto Generated by Entity Framework . i was filling incorrect thing
希望可能会有所帮助。
这篇关于解决:有一个错误产生“..Context”。尝试重建项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!