ef mysql 0152,EF代码首先将Mysql转换为SQL Server

I have an MVC 5 application that I first configured to use Mysql but now would like it to use SQL Server.

My app uses code first and migrations in order to generate the database.

After I changed all the required configuration I tried to run a Update-Database from the Package management console but I keep getting this error:

System.Data.Entity.Core.MetadataException: Schema specified is not

valid. Errors: (0,0) : error 0152: No Entity Framework provider found

for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient'.

Make sure the provider is registered in the 'entityFramework' section

of the application config file. See

http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

This error appears after the database is created. It also appears when I run the application since it checks at that moment if there is any migration to do.

Somehow it still tries to use MySQL even though all providers point to SQL Server.

Any help would be more than welcome.

Thanks in advance

解决方案

You need to follow the below mentioned steps to overcome above issue.

Step 1 : Use NuGet package to remove and install the relevant packages.This is very important.

If it's not working after the above step then you have to follow the below mentioned steps.

Step 1 : Get a backup of your project and SQL db and keep it in a safe place.

Step 2 : After that you have to delete all your data migration scripts on your app.

Step 3 : Delete the SQL db also.

Step 4 : Recreate all your Migration scripts again and after that run those against the SQL server.

Note : You need to do above steps b'cos it seems EF keep the provider details on the db migration scripts.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值