2

Kestrel (DNX) を使用してロードしようとしている、MySQL.Data.Entity.EF6 を使用する MVC5 プロジェクトがあります。

ただし、ページの読み込み時に次のエラーが引き続き発生します。

MetadataException: Schema specified is not valid. Errors: 
CMaxModel.ssdl(2,2) : 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. See 
http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

この構成を使用して作成しましたDbContext

public class MyDbConfiguration : DbConfiguration
{
    public MyDbConfiguration()
    {
        // Register ADO.NET provider
        var dataSet = (DataSet)ConfigurationManager.GetSection("system.data");
        dataSet.Tables[0].Rows.Add(
            "MySQL Data Provider",
            ".Net Framework Data Provider for MySQL",
            "MySql.Data.MySqlClient",
            typeof(MySqlClientFactory).AssemblyQualifiedName
        );

        // Register Entity Framework provider
        SetProviderServices("MySql.Data.MySqlClient", new MySqlProviderServices());
        SetDefaultConnectionFactory(new MySqlConnectionFactory());
    }
}


[DbConfigurationType(typeof(MyDbConfiguration))]
public partial class CMax : DbContext
{
    public CMax(string connectionString)
        : base(connectionString)
    {
    }

MVC が web.config を使用しないことを読んだことからでも、wwwroot で、Web.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>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider>
    </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.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>

  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%"     stdoutLogEnabled="false" startupTimeLimit="3600"/>
  </system.webServer>

</configuration>

私は完全に途方に暮れています。どんな助けもいただければ幸いです。

4

0 に答える 0