简体   繁体   English

实体框架6.20,必须将System.Data.Objects更改为System.Data.Entity.Core.Objects;

[英]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.

相关问题 为什么必须添加System.Data.Entity才能使用System.Data.Objects? - Why do I have to add System.Data.Entity to use System.Data.Objects? 为什么实体框架System.Data.Entity.Core.Objects.RelationshipEntry错误? (用于变更跟踪) - Why is the Entity Framework System.Data.Entity.Core.Objects.RelationshipEntry Wrong? ( For Change Tracking) System.Data.Objects中对象集类的签名的含义 - meaning of signature of Object set class in System.Data.Objects System.Data.Entity.Core.Objects.ObjectParameter获取null - System.Data.Entity.Core.Objects.ObjectParameter Gets null 无法将类型System.Data.Entity.Core.Objects.ObjectResult隐式转换为System.Data.Objects.ObjectResult - Cannot implicitly convert type System.Data.Entity.Core.Objects.ObjectResult to System.Data.Objects.ObjectResult 无法从&#39;System.Data.Objects.ObjectParameter&#39;转换为&#39;System.Data.Entity.Core.Objects.ObjectParameter&#39; - cannot convert from 'System.Data.Objects.ObjectParameter' to 'System.Data.Entity.Core.Objects.ObjectParameter' 不能使用类型为System.Data.Entity.Core.Objects.ObjectQuery的实例调用System.Data.Entity.DbSet - System.Data.Entity.DbSet cannot be called with instance of type System.Data.Entity.Core.Objects.ObjectQuery Entity Framework Core 2.2.4中System.Data.Entity的等价物是什么? - What is the equivalent of System.Data.Entity in Entity Framework Core 2.2.4? 无法将“System.Linq.IQueryable”中的匿名类型转换为“System.Data.Entity.Core.Objects.ObjectQuery” - Unable to cast Anonymous Type from 'System.Linq.IQueryable' to 'System.Data.Entity.Core.Objects.ObjectQuery' 无法将类型&#39;System.Data.Entity.Core.Objects.ObjectResult &lt;&gt;&#39;隐式转换为&#39;System.Collections.Generic.List &lt;&gt;&#39; - Cannot implicitly convert type 'System.Data.Entity.Core.Objects.ObjectResult<>' to 'System.Collections.Generic.List<>'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM