gpt4 book ai didi

c# - 类型 : 'MySql.Data.Entity.MySqlEFConfiguration' 违反的继承安全规则

转载 作者:IT老高 更新时间:2023-10-28 23:49:28 24 4
gpt4 key购买 nike

我创建了一个 asp.net Web 应用程序,它应该连接到一个 mysql 数据库。

我正在使用带有 ado.net 实体数据模型的 Entity Framework 6。我还遵循了以下教程:https://dev.mysql.com/doc/connectors/en/connector-net-entityframework60.html#connector-net-ef6-config

然而调用:DbConfiguration.SetConfiguration(new MySqlEFConfiguration());

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

任何想法是什么导致了这个错误?

  • .NET 框架:4.6.1
  • MySql.Data.Entity.EF6:6.10.4

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>

完全错误:

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.

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.

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 降级到旧版本,它解决了我的问题。

关于c# - 类型 : 'MySql.Data.Entity.MySqlEFConfiguration' 违反的继承安全规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47227495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com