EF 数据迁移 常见错误

注意:ef项目最好设置为启动项目,且在配置文件中把数据库地址加上!!!

错误 “LC.exe”已退出,代码为 -1
原因:解决方案出错,而非迁移的项目

字段怎么迁移 都写入不到数据库 也没有报错提示
原因:眼瞎 如:public string Name { get; }
备注:近视也是老火

错误:Build failed.
解决:移除test项目,框架用的abp

错误:实例失败
解决:把项目 SimpleTaskSystem.EntityFramework 设置为启动项

错误:无法将“Update-Database”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
解决:在 程序包管理器控制器 (针对下载好的abp项目哈)
1、Install-Package EntityFramework
2、Update-Database -verbose
原文:https://www.cnblogs.com/wushanghong/articles/4900223.html

错误:No migrations configuration type was found in the assembly 'MyProject.Web'.
(In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
解决:默认项目 选择 EntityFramework

迁移的时候总是连接这个:Target database is: 'MyProject3' (DataSource: .SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Convention).
原因还未找到
数据库地址明明配置的这个:
<add name="MyProject3" connectionString="DataSource=localhost; Database=Default;uid=sa;password=sa; />
解决:在含有EF框架的项目中,添加App.config,再把数据库地址添上 好像可以就了。
基于core的abp项目,直接改web层的appsettings.json里面的数据库连接,也可以实现数据迁移

原文地址:https://www.cnblogs.com/guxingy/p/13282910.html