我有一个MVC5项目,使用MySQL.Data.Entity.EF6,我试图使用Kestrel(DNX)加载。
但是,我继续在页面加载时出现此错误:
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>
我完全失去了,任何帮助都将不胜感激。