2017-01-13 21 views
0

私は、EF6を使用してMySQLデータベースにリンクされたビジュアルスタジオ(Web MVCアプリケーション)のプロジェクトを持っています。すべてが動作している、私はプロバイダがweb.configで参照して、すべてが正しいです。ここで、データアクセスをタイプクラスライブラリの新しいプロジェクトに分けたいと思います。私はプロジェクトを作成し、参照(MySql.DataとMySql.Data.Entity.EF6)を追加し、プロバイダをapp.configに追加しました。私はすべての手順を実行したと思いますが、作成しようとすると固くなりました。新しいデータコンテキストには、以下のエラーがあります。Entity Framework 6 with MySQL - クラスライブラリ

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <section name="dPhotos.data.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> 
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </sectionGroup> 
    </configSections> 
    <connectionStrings> 
    <add name="DefaultConnection" connectionString="metadata=res://*/Models.teste.csdl|res://*/Models.teste.ssdl|res://*/Models.teste.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=###############;user id=#############;password=############;database=###########&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers> 
     <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider> 
    </providers> 
    </entityFramework> 
    <userSettings> 
    <dPhotos.data.Properties.Settings> 
     <setting name="fdsgd" serializeAs="String"> 
     <value>fdgd</value> 
     </setting> 
    </dPhotos.data.Properties.Settings> 
    </userSettings> 
</configuration> 

enter image description here enter image description here

答えて

0

これを試してみてください:

On your machine where Visual Studio is installed, MySQL VS plugin and Connector/Net 

Close all VS instances before doing the steps. 

On a Windows Explorer window go to this path or wherever you installed you Connector/net binaries 

C:\Program Files (x86)\MySQL\MySQL Connector Net {version}\Assemblies\v4.5\ 

Copy the file: 

MySql.Data.Entity.EF6.dll 

And paste it to this folder 

C:\Program Files (x86)\Microsoft Visual Studio {version}\Common7\IDE\PrivateAssemblies 

If it asks you to overwrite it please do so. 

You'll need admin rights in order to overwrite the file. 

Add reference of this DLL into the project. 

Then you can try again to generate the script for your model. 

あなたのapp.configは、次のようになります。

<?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="dPhotosEntities" connectionString="metadata=res://*/Models.dPhotosModel.csdl|res://*/Models.dPhotosModel.ssdl|res://*/Models.dPhotosModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;password=######;user id=######;server=######;persistsecurityinfo=True;database=######&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <entityFramework> 
    <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> 
</configuration> 
関連する問題