热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ef6连接mysql无法错误_ef6下mysql数据库迁移发生错误:DbMigrationsConfigurationthrewanexception...

错误提示:ThetypeinitializerforSystem.Data.Entity.Migrations.DbMigrationsConfiguration1t

错误提示:

The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception.

异常详细信息:

PM> add-migration InitialModel

System.TypeInitializationException: The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception. ---> System.InvalidOperationException: The DbConfiguration type 'MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6' specified in the application config file could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information. ---> 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.

at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)

at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)

at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)

at System.Type.GetType(String typeName, Boolean throwOnError)

at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationLoader.TryLoadFromConfig(AppConfig config)

--- End of inner exception stack trace ---

at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationLoader.TryLoadFromConfig(AppConfig config)

at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForAssembly(Assembly assemblyHint, Type contextTypeHint)

at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForContext(Type contextType)

at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..cctor()

--- End of inner exception stack trace ---

at System.Data.Entity.Migrations.DbMigrationsConfiguration`1..ctor()

at EF.Demo.MySql.Migrations.Configuration..ctor() in D:\SourceCode\ZhaoCode\ToolsAndFrameworks\EntityFramework\EF.Demo.MySql\Migrations\Configuration.cs:line 10

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)

at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()

at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.RunCore()

at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

上下文代码:

[DbConfigurationType(typeof(MySqlEFConfiguration))]

public class Context : DbContext

{

public Context() : base("name=MyContext")

{

}

public DbSet Users { get; set; }

}

配置文件:

寻求一个解决办法,多谢。



推荐阅读
author-avatar
xiaoge
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有