ModelConfiguration does not exist in the namespace 'System.Data.Entity'

别来无恙 提交于 2020-01-07 03:03:48

问题


I'm trying to get a template working that will correctly rename my navigation properties in the entity framework. Here are first five lines of the template:

<#@ template language="C#" debug="true" hostSpecific="true" #>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ assembly name="System.Text.RegularExpressions"#>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="System.Data.Entity.ModelConfiguration.Mappers" #>

However when I try to "Run the Custom Tool" I get the following error:

Error Compiling transformation: The type or namespace name 'ModelConfiguration' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?) c:\Users\Clay\AppData\Local\Temp\05ugyat2.0.cs 21

The solution has EntityFramework 6.1.3 installed as a NuGet package. However I (strangely) also had to add a reference to System.Data.Entity (V4.0.0.0) to the project. My understanding from reading comments in other similar SO questions is that you should only need to add the reference if the package isn't part of your solution. When I added the reference it I could see System.Data.Entity in the Object Browser.

I added the assembly into the project's Web.config:

<compilation debug="true" targetFramework="4.5.2">
  <assemblies>
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>

Still getting the error! Any help would be much appreciated.

来源:https://stackoverflow.com/questions/35334184/modelconfiguration-does-not-exist-in-the-namespace-system-data-entity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!