Code First for Mysql 错误:未为提供程序“MySql.Data.MySqlClient”找到任何 MigrationSqlGenerator

mysql 数据库迁移报错:

  1. PM> add-migration udpate2015_9_20  
  2. <span style="color:#ff0000;">未为提供程序“MySql.Data.MySqlClient”找到任何 MigrationSqlGenerator。请在目标迁移配置类中使用 SetSqlGenerator 方法以注册其他 SQL 生成器。</span>  


错误的原因:

没有指定当前上线文所处的程序集

  1. [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]  
  2. public class WLContext : DbContext  
  3. {  
  4.   
  5. }  
  1. // 摘要:   酷站网软
  2. //     可将此属性置于 System.Data.Entity.DbContext 的子类上,以指示 System.Data.Entity.DbConfiguration  
  3. //     的子类,后者表示应用程序的基于代码的配置与上下文类型处于不同的程序集中。  
  4. [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]  
  5. [SuppressMessage("Microsoft.Design""CA1019:DefineAccessorsForAttributeArguments")]  
  6. [SuppressMessage("Microsoft.Performance""CA1813:AvoidUnsealedAttributes")]  
  7. public class DbConfigurationTypeAttribute : Attribute  
  8. {  
  9.     // 摘要:   软盘
  10.     //     指示应对此应用程序的基于代码的配置使用由给定程序集限定名称表示的 System.Data.Entity.DbConfiguration 的子类。  
  11.     //  
  12.     // 参数:   
  13.     //   configurationTypeName:  
  14.     //     要使用的 System.Data.Entity.DbConfiguration 类型。  
  15.     public DbConfigurationTypeAttribute(string configurationTypeName);  
  16.     //  
  17.     // 摘要:   
  18.     //     指示应对此应用程序的基于代码的配置使用 System.Data.Entity.DbConfiguration 的给定子类。  
  19.     //  
  20.     // 参数:   
  21.     //   configurationType:  
  22.     //     要使用的 System.Data.Entity.DbConfiguration 类型。  
  23.     public DbConfigurationTypeAttribute(Type configurationType);  
  24.   
  25.     // 摘要:   
  26.     //     获取应对此应用程序的基于代码的配置使用的 System.Data.Entity.DbConfiguration 的子类。  
  27.     //  
  28.     // 返回结果:   
  29.     //     应对此应用程序的基于代码的配置使用的 System.Data.Entity.DbConfiguration 的子类。  
  30.     public Type ConfigurationType { get; }  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值