实体框架Powertools用Mysql和EF6生成视图 [英] Entity Framework Powertools Generating Views with Mysql and EF6

查看:502
本文介绍了实体框架Powertools用Mysql和EF6生成视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MySQL 5.5.35和EF Powertools(最新版本)的Entity Framework 6.1。我可以运行并使用框架,并在应用程序配置文件中注册所有正确的提供程序详细信息。



我遇到问题是我无法使用右键单击电动工具函数生成视图,它不断抛出这个异常:



System.Reflection.TargetInvocationException:调用目标抛出异常。 ---> System.Data.Entity.Core.MetadataException:指定的模式无效。错误:
Model1.edmx(7,8):错误0152:未找到具有不变名称MySql.Data.MySqlClient的ADO.NET提供程序的实体框架提供程序。确保提供程序已注册在应用程序配置文件的entityFramework部分。



我明白什么是问题,因为我最初在运行我的项目时遇到这个问题,但是尽管在运行和编译生成视图功能时可以正常工作抛出此错误。我只能假设电动工具正在寻找其他位置的供应商,而不是我们的应用程序配置文件,因为他们注册了他们的。



有没有人有什么想法在哪里它可能会得到提供者列表,也许从全局系统配置文件?我没有真正的经历,在搜索几个小时没有任何东西。



任何帮助将不胜感激或指向正确的方向。
谢谢

解决方案

首先,尝试使用较低版本的Entity Framework。当我使用MySql时,EF6目前不支持Mysql。如果你有6.8.x的连接器,但是我仍然不太清楚6.1,这显然是可以使用的。
您可以在这里看到以下信息: EF6。 0连接器



有几个原因可能导致:
您确定在App.config或Web.config中有这样的部分?:

 < entityFramework> 
< providers>
< provider invariantName =MySql.Data.MySqlClienttype =MySql.Data.MySqlClient.MySqlProviderServices,MySql.Data.Entity/>
< / providers>
< / entityFramework>

当我使用MySql时,我也不得不添加以下代码,不知道为什么因为我不需要当我使用SQL Server ...
[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class DemoContext:DbContext {}


I am using Entity Framework 6.1 with MySQL Server 5.5.35, and EF Powertools (latest version). I am able to run and use the framework fine and registered all the correct provider details in the application configuration file.

Where I am having an issue is that I cannot use the right click Power tool function Generate Views, it keeps throwing up this exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: Model1.edmx(7,8) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file.

I understand what is asking because I struggled with this issue when running my project originally, but although it works fine when running and compiling the generate views function throws this error. I can only assume that the Power tools is looking for the providers in another location and not my Application Configuration file as they are registered their.

Does anyone have any ideas on where it may get the providers list, maybe from the global system config file? I am not really experienced with that and after searching for hours have come up with nothing.

Any help would be appreciated or pointing in right direction. Thanks

解决方案

First reason, try using a lower version of Entity Framework. When i used MySql, EF6 didn't support Mysql at this time. It's apparently avalaible now for 6.0 if you have the connector 6.8.x but i'm still not sure about 6.1. You can see the infos here : EF6.0 connector

Several reasons might leads to that : Are you sure to have a section like this in your App.config or Web.config ?:

<entityFramework>
  <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
      </providers>
</entityFramework>

I also had to add the following code when i worked with MySql, don't know why because i don't have to when i work with SQL Server ... [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))] public class DemoContext : DbContext{}

这篇关于实体框架Powertools用Mysql和EF6生成视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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