我最近开始了具有多层架构的 ASP.net 核心项目,其中 CatalogDbContext 和 StartUp 类在不同的层中:
我想将迁移添加到 DroneStore.Data 层。我在命令提示符下将当前目录更改为 ../DroneStore.Data/并添加命令:
dotnet ef migrations add Initial
出现错误:
Unable to create an object of type 'CatalogDbContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
当我将当前目录更改为 ../DroneStore.Web/并添加此命令时,出现错误:
Your target project 'DroneStore.Web' doesn't match your migrations assembly 'DroneStore.Data'. Either change your target project or change your migrations assembly
有什么建议吗?
最佳答案
1) 在命令提示符下将当前目录更改为:
cd ../DroneStore.Data/
2) 添加到带有启动项目文件夹路径的命令 -s 选项:
dotnet ef migrations add Initial -s ../DroneStore.Web/
关于c# - EF core 在 ASP.net core 多层架构中添加迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54685859/