实体框架6找不到&LT CLR类型;模型方式><实体GT; [英] Entity Framework 6 Could not find the CLR type for <model>.<entity>

查看:1429
本文介绍了实体框架6找不到&LT CLR类型;模型方式><实体GT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,asp.net web的表单4.5 C#与EF6 DB-第一,
我正在从近一年,一切工作正常,直到今天,当我试图将新视图添加到从数据库中EDMX更新。
该表即被添加没有错误,但是从code是不可见的,如果我尝试附加到EntityDataSource,我得到的消息找不到CLR类型。

I have a web application, asp.net web-form 4.5 C# with EF6 DB-first, I'm working on it from almost one year, everything was working fine until today, when I've tried to add a new view to the edmx updating from the database. The table is added with no errors, but from the code is not visible, and if I try to attach to an EntityDataSource, I get the message "Could not find the CLR type for ."

我见过的code生成策略设置为 T4
如果我改变为传统的ObjectContext 的新实体正确地出现在code和EntityDataSource工作得很好,我可以完全看到GridView控件有关,
但如果我尝试导航到我接触到其他的老实体其他页面,我得到的错误的几行:

I've seen that the code generation strategy is set to T4. If I change to "Legacy ObjectContext" the new entity is correctly seen in the code and EntityDataSource works fine, I can perfectly see the gridview associated, but if I try to navigate to some other page where I access to the other "old" entities, I get several lines of errors:

指定的模式是无效的。错误:
CLR类型EDM类型的映射,因为多个CLR类型匹配EDM类型报告是不明确的。 previously发现CLR类型报告,新发现的CLR类型'AppNameModel.Report
因为多个CLR类型匹配EDM类型的客户CLR类型EDM类型的映射是模糊的。 previously发现CLR类型客户,新发现的CLR类型'AppNameModel.Customer。
....等等所有previously创建实体(最后一个未列出,并与传统objCtx战略的作品!)

Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Report'. Previously found CLR type 'Report', newly found CLR type 'AppNameModel.Report'. The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Customer'. Previously found CLR type 'Customer', newly found CLR type 'AppNameModel.Customer'. ....and so on for all the previously created entities (last one is not listed and works with legacy objCtx strategy!)

那么,什么是错EF ??!我读过所有的Q&功放;在堆栈溢出A,但没有似乎有一个解决方案

So what's wrong with EF??! I've read all the Q&A on stack overflow, but none seems to have a solution.

我把web.config中的某些部分:

I'll put some part of the web.config:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

...

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="v11.0" />
  </parameters>
</defaultConnectionFactory>
<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>

这里是EDMX的属性:

here is the properties of the edmx:

当我使用T4策略添加的看法,其实,认为是不是在被定义的实体的任何文件present,只显示在emdx可视化设计。我已经在文件的.cs和.context.cs检查

When I add the view using T4 strategy, actually, the view is not present in any file where are defined the entity, is only displayed on the emdx visual designer. I've checked in the file .cs and in .context.cs

请给一些投入,在那里我有看,我怎么能解决......一些方向!谢谢

Please give some input, where I have to look, how can I fix...some direction! thanks

推荐答案

我还没有发现是什么原因造成的问题,顺便我已经找到了解决方法:

I haven't yet discovered what has caused the issue, by the way I have found a workaround:

运行自定义工具在两个​​ .TT 关联到你的EDMX文件。
这两个文件保存自动生成的code,如果自动生成不工作了,运行自定义工具,你强迫它到C相应地更新$ C $您EDMX模型。

Run the Custom Tool on the two .tt files associated to your edmx. This two files hold the auto generated code, if the auto-generation doesn't work anymore, running the custom tool you force it to update the code accordingly to your edmx model.

这篇关于实体框架6找不到&LT CLR类型;模型方式&gt;&LT;实体GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆