MySQL在VS Express 2012版本的实体框架的数据库更新模型中未列出 [英] MySQL not Listed in Updated model from Database for entity framework in VS Express 2012 edition
问题描述
请参阅内嵌图片:
我已经安装了MySQL for visual studio,这样我就可以看到现有的数据模型由别人创建,
,但我无法更新数据模型。
我也尝试了这里给出的解决方案:
无法创建实体数据模型 - 使用MySql和EF6 ,但没有解决。
似乎有一些问题VS 2012快递版。
我需要知道这是VS 2012 express的一个问题,或者我错过了一些,
如何将MySQL列为数据源?
任何帮助将非常感激。
AFAIK,VS 2012 Express不支持 MySQL for Visual Studio
作为扩展名,但由 MySQL Connector / NET
支持,根据这篇文章:
Visual Studio的MySQL不支持Microsoft
开发产品的Express版本,包括Visual Studio和Microsoft
Visual Web Developer。
要使用MySQL Connector / Net与Microsoft开发产品的Express版本,请使用MySQL Connector / Net 6.7.4或更高版本,而无需安装Visual Studio的MySQL。
以下是使用Connector / NET与EF的一些步骤:
-
安装MySQL Connector / NET,在您的项目中添加3个以下DLL文件作为参考:
MySql.Data.dll
MySql.Data.Entity.dll(对于EF6,它应该是MySql.Data.Entity.EF6.dll)
MySql.Web.dll
所需的文件存在于 MySQL\MySQL Connector Net [版本号] \Assemblies\ [.NET版本] \
,例如C $ \\ C code $ \\ b $ b
- 在
web.config $ c $中更改
entityFramework
元素c>文件取决于使用的EF版本:
EF 5
< entityFramework>
< defaultConnectionFactory type =MySql.Data.Entity.MySqlConnectionFactory,MySql.Data.Entity/>
< / entityFramework>
EF 6
< entityFramework codeConfigurationType =MySql.Data.Entity.MySqlEFConfiguration,MySql.Data.Entity.EF6>
< defaultConnectionFactory type =System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework/>
< providers>
< provider invariantName =MySql.Data.MySqlClienttype =MySql.Data.MySqlClient.MySqlProviderServices,MySql.Data.Entity.EF6/>
< / providers>
< / entityFramework>
- 重建项目/解决方案,并确保数据源下拉列表中提供MySQL数据库选项。
更新:
在进一步研究数据源可用性后,我发现Visual Studio Express版本对第三方扩展有一定的限制,因此在某些情况下甚至不允许在EDM设计时创建与MySQL实例的连接(感谢 Devart 提醒我这个)。作为解决方法,可以使用基于CLI的EDM生成器(请参阅示例和使用说明),例如:
edmgen.exe / mode:fullgeneration / c:[MySQL DB connection string]/ project:[project name] / entitycontainer:[entity name ] / namespace:[table namespace] / language:CSharp
相关问题:
Visual Studio 2012上的mySQL DataSource
MySQL for Visual Studio 2012/2013
i am trying to update model from database and use MySQL as my data source, it seems like there is some problem in listing MySQL as datasource . Please see the inline image : I have installed MySQL for visual studio , that way i am able to see the existing data model,created by someone else, but i can't update the data model. Also i tried the solution given here : Can't Create Entity Data Model - using MySql and EF6 , but it didn't worked out .
It seems like there is some problem with VS 2012 express edition.
I need to know is this an issue with VS 2012 express , or am I missing something,
How to list MySQL as the data source ?? Any help would be really appreciated.
解决方案AFAIK, VS 2012 Express doesn't supported by
MySQL for Visual Studio
as extension but supported byMySQL Connector/NET
, according to this article:MySQL for Visual Studio does not support Express versions of Microsoft development products, including the Visual Studio and the Microsoft Visual Web Developer.
To use MySQL Connector/Net with an Express versions of Microsoft development products, use MySQL Connector/Net 6.7.4 or later, without installing the MySQL for Visual Studio.
Here are some steps to use Connector/NET with EF:
Install MySQL Connector/NET, add 3 following DLL files as reference in your project:
MySql.Data.dll MySql.Data.Entity.dll (for EF6 it should be MySql.Data.Entity.EF6.dll) MySql.Web.dll
The required files exist on
MySQL\MySQL Connector Net [version number]\Assemblies\[.NET version]\
, e.g.C:\Program Files\MySQL\MySQL Connector Net 6.x.x\Assemblies\v4.5\
.
- Change
entityFramework
element on yourweb.config
file depending on EF version being used:EF 5
<entityFramework> <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity" /> </entityFramework>
EF 6
<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6"> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> </providers> </entityFramework>
- Rebuild your project/solution and ensure "MySQL Database" option is available on data source dropdown list.
Update:
After conducting further research regarding data source availability, I found that Visual Studio Express editions have certain set of limitations regarding third party extensions, hence in some cases doesn't allow even creating connection to MySQL instance in EDM design-time (thanks to Devart reminds me about this). As a workaround, CLI-based EDM Generator may be used (see example and usage description) like this example:
edmgen.exe /mode:fullgeneration /c:"[MySQL DB connection string]" /project:[project name] /entitycontainer:[entity name] /namespace:[table namespace] /language:CSharp
Related issues:
mySQL DataSource on Visual Studio 2012
Can't use a MySQL connection for entity framework 6
MySQL For Visual Studio 2012/2013
这篇关于MySQL在VS Express 2012版本的实体框架的数据库更新模型中未列出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!