[英]Entity Framework 6.20, keep having to change System.Data.Objects to System.Data.Entity.Core.Objects;
I'm using the Entity Framework 6.20 with c#, Visual Studio 2017. 我正在将Entity Framework 6.20与c#,Visual Studio 2017一起使用。
Whenever I update my object model from the database in my Model.Context.cs my lines: 每当我从Model.Context.cs中的数据库更新对象模型时,我的代码行:
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Core.Objects.DataClasses;
automatically change to 自动更改为
using System.Data.Objects;
using System.Data.Objects.DataClasses;
then I get many errors saying: 然后我得到很多错误说:
The type or namespace name 'Objects' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) 类型或名称空间名称“ Objects”在名称空间“ System.Data”中不存在(您是否缺少程序集引用?)
So I just need to change the two lines back to how they were, but why is this happening? 因此,我只需要将这两行更改为原来的样子,为什么会这样呢? Can I stop it happening? 我能阻止它发生吗?
Thanks - Ben 谢谢-本
Maybe this is because your .tt are outdated or you have had a update/migration from one entity framework version to another 可能是因为您的.tt已过时,或者您已经从一个实体框架版本更新/迁移到另一个实体框架版本
The Model.Context.cs is automatically generated, so you can edit it you Model.Context.tt (this is a T4 template used to generated code automatically) Model.Context.cs是自动生成的,因此您可以在Model.Context.tt中对其进行编辑(这是用于自动生成代码的T4模板)
in solution explorer open the file Model.Context.tt Then search the using lines that given you the errors , modify with the correct values and save the file, later right clik over this file and select Run Custom Tool. 在解决方案资源管理器中,打开文件Model.Context.tt,然后搜索出现错误的使用行,并使用正确的值进行修改并保存文件,然后右键单击该文件并选择“运行自定义工具”。
I'll hope that this will be the solution, regards 我希望这将是解决方案,问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.