vs2013, EF6.0.0.0 使用Migrations来更新数据库时报错

1、vs中,程序包管理器控制台

2、执行,Enable-Migrations

报错:

Migrations have already been enabled in project 'dd'. To overwrite the existing migrations configuration, use the -Force parameter.

3、执行,Enable-Migrations -Force

报错:

The migrations configuration type 'dd.Configuration' was not be found in the assembly 'dd'.

原因:

执行这个命令时,程序会首先去本地的GAC目录Assembly中找该配置文件,如果之前部署的程序里面不包含这个configuration,那么就会出现上面这个错误。

当然,网上也可以找到其他的一些解决方案,但查到的方法都不适用我的这种情况。

4、删除GAC目录下对应的程序集(或者剪切到其他的文件夹里),再次执行,Enable-Migrations -Force,发现可以了。:)

原文地址:https://www.cnblogs.com/lishidefengchen/p/5512810.html