EF CORE 使用过程中常见的错误
问题:Your startup project ‘NetCore.3.Project’ doesn’t reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
解决方法:启动项目“ NetCore.3.Project” 安装: Microsoft.EntityFrameworkCore.Design
问题:add-migration : 无法将“add-migration”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
解决方法:启动项目“ NetCore.3.Project” 安装:Microsoft.EntityFrameworkCore.Tools
问题:Your target project ‘NetCore5.Demo’ doesn’t match your migrations assembly ‘DBDemo’. Either change your target project or change your migrations assembly.
解决方法1:运行工具的项目与类不在相同的程序集中:如图所示
解决方法2:(此方法一劳永逸):如图所示