类型违反了继承安全规则:"MySql.Data.Entity.MySqlEFConfiguration" [英] Inheritance security rules violated by type: 'MySql.Data.Entity.MySqlEFConfiguration'

查看:177
本文介绍了类型违反了继承安全规则:"MySql.Data.Entity.MySqlEFConfiguration"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个应连接到mysql数据库的asp.net Web应用程序.

I've created an asp.net web application which should connect to a mysql database.

我正在使用带有ado.net实体数据模型的实体框架6.我还遵循了以下教程:

I´m using entity framework 6 with an ado.net entity data model. I´ve also followed the following tutorial: https://dev.mysql.com/doc/connectors/en/connector-net-entityframework60.html#connector-net-ef6-config

但是调用:DbConfiguration.SetConfiguration(new MySqlEFConfiguration());

使我的应用程序崩溃.它可能与该特定方法无关,因为创建DBContext也会使应用程序崩溃.

causes my application to crash. It probably has nothing to do with this specific method, because creating a DBContext also crashes the app.

有什么想法导致此错误吗?

Any ideas what's causing this error?

  • .NET Framework:4.6.1
  • MySql.Data.Entity.EF6:6.10.4

Web.config:

Web.config:

<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>
      <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 invariantName="System.Data.SqlClient"
                type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>

<connectionStrings><add name="DatabaseEntities" connectionString="metadata=res://*/Database.Model.csdl|res://*/Database.Model.ssdl|res://*/Database.Model.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;&quot;" providerName="System.Data.EntityClient" /></connectionStrings><system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add description=".Net Framework Data Provider for MySQL" invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

完全错误:

违反类型的继承安全性规则: 'MySql.Data.Entity.MySqlEFConfiguration'.派生类型必须是 匹配基本类型的安全可访问性或更少 可访问的.

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.

描述:在执行当前Web请求期间发生未处理的异常.请检查堆栈跟踪 有关该错误及其起源的更多信息 代码.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.TypeLoadException:类型违反的继承安全性规则: 'MySql.Data.Entity.MySqlEFConfiguration'.派生类型必须是 匹配基本类型的安全可访问性或更少 可访问的.

Exception Details: System.TypeLoadException: 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.EF6降级到较旧的版本,并解决了我的问题.

I downgraded MySql.Data.Entity.EF6 to an older version and it solved my problem.

这篇关于类型违反了继承安全规则:"MySql.Data.Entity.MySqlEFConfiguration"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆