我正在尝试使用我的模型并从中创建数据库。当我尝试基于模型生成数据库时,我收到以下错误:
运行转换:System.InvalidOperationException:由名为'CsdlToSsdlAndMslActivity'的活动生成的SSDL无效,并且有以下错误:
没有为ADO.NET提供程序找到具有不变名称“MySql.Data.MySqlClient”的实体框架提供程序。确保提供程序已在应用程序配置文件的“entityFramework”部分中注册。有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=260882。at Microsoft.Data.Entity.Design.DatabaseGeneration.EdmExtension.CreateAndValidateStoreItemCollection(String ssdl, Version targetFrameworkVersion, IDbDependencyResolver resolver, Boolean catchThrowNamingConflicts) at Microsoft.VisualStudio.TextTemplatingFED2D73CEED00C99E8A0A14FA9AE33EAFFDF3CAAFEE9E04D21CC913F1C5C88D960592C81A433C11663E61FD5459CF679CFD9B7275B72CA8BFB8D753DBB9FDDE3.GeneratedTextTransformation.get_Store() in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\GenerateTSQL.Utility.ttinclude:line 57 at Microsoft.VisualStudio.TextTemplatingFED2D73CEED00C99E8A0A14FA9AE33EAFFDF3CAAFEE9E04D21CC913F1C5C88D960592C81A433C11663E61FD5459CF679CFD9B7275B72CA8BFB8D753DBB9FDDE3.GeneratedTextTransformation.TransformText() in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen\SSDLToSQL10.tt:line 84 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\GenerateTSQL.Utility.ttinclude 57
如果有任何帮助,以下内容包含我的App.config:
GetPurchases()
我知道问题出在基于错误消息的<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="SomeDatabase" providerName="MySql.Data.MySqlClient" connectionString="password=user;server=192.168.0.114;uid=hello;database=example;persistsecurityinfo=True;" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<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, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"></assemblyBinding>
</runtime>
</configuration>
,但我似乎无法弄清楚它希望我做什么。我已将MySql.Data.MySqlClient
,MySql.Data
和MySql.Data.Entity.EF6
添加到项目中。
任何人都知道如何解决这个问题?
答案 0 :(得分:0)
在此之前我遇到了同样的问题。我设法通过创建一个全新的项目来解决它。
转到Manage NuGet Packages
,安装EntityFramework
,MySql.ConnectorNET.Data
和MySql.ConnectorNET.Entity
。
使用此处显示的连接字符串<add name="SomeDatabase" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=example;uid=hello;password=user"/>
在DbContext类中添加[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
。