Enity Framework With MySQL

后端 未结 4 2000
滥情空心
滥情空心 2020-12-09 11:40

I am getting the following error

\"The Entity Framework provider type \'MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity\' registered in the applicati

相关标签:
4条回答
  • 2020-12-09 12:24

    for anyone facing the same problem, here is the line that causes the Exception is this

    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
    

    Just append .EF6 to MySql.Data.Entity such that the provider is like this

    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    

    As such your choice to remove the code within didn't help solve the problem. I hope this helps someone.

    0 讨论(0)
  • 2020-12-09 12:25
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <connectionStrings>
        <add name="inspectm_inspectContext" connectionString="server=--;user id=--;password=--;database=--;persistsecurityinfo=True" providerName="MySql.Data.MySqlClient" />
      </connectionStrings>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
         <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
          <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
         </providers>
      </entityFramework>
    </configuration>
    

    My Complete App.conf this worked for me

    First I removed

    <DbProviderFactories>
    <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.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
    

    Then I changed

    <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
    

    And Added the provider

    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
    
    0 讨论(0)
  • 2020-12-09 12:30

    You Could Also Do the Following

    [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
    public class DemoContext : DbContext{}
    {
    
    0 讨论(0)
  • 2020-12-09 12:30

    Check for an inner exception.

    I get

    {"Inheritance security rules violated by type: 'MySql.Data.Entity.MySqlEFConfiguration'. Derived types must either match the security accessibility of the base type or be less accessible.":"MySql.Data.Entity.MySqlEFConfiguration"}

    That points me to: Inheritance security rules violated by type: 'MySql.Data.Entity.MySqlEFConfiguration'

    I dont really like to downgrade. But so far i haven't found a better answer.

    0 讨论(0)
提交回复
热议问题