【发布时间】:2021-08-26 22:57:56
【问题描述】:
我正在尝试在另一个项目中添加迁移,而我在这里确实是白发苍苍,尝试到处找到不同的解决方案,但都没有奏效,我只是不明白为什么不起作用。
我在 Startup.cs 中有这个
services.AddDbContext<ApplicationDbContext>(
c => c.UseSqlServer(_config.GetConnectionString("ApplicationDbContext"),
opt => opt.MigrationsAssembly("DatabaseContext.Migrations")));
我确实检查了this、this、this,我想还有一些其他的,我不知道出了什么问题。
对于我的解决方案结构如下:
Shop (former empty solution)
1. DatabaseSchema (folder with empty spaces)
DatabaseContext (project with the migrations folder inside)
..
bunch of other stuff
..
ShopApi (here I have that code above in Startup.cs)
我试过了:
dotnet ef 迁移添加 ExampleMigration -s ../ShopAPI dotnet ef 迁移脚本 --project DatabaseContext --startup-project ../ShopAPI
它只是说没有找到项目,我不明白路径有什么问题,我向上一个文件夹,项目就在那里。由于它变得非常烦人并且我很紧张,我尝试了所有路径组合,但仍然没有找到任何东西。
路径是这样的:
Shop (Solution) -> 1. DatabaseSchema (Folder) -> DatabaseContext/Migrations
-> ShopAPI (is where I have my Startup.cs)
这里有什么不明白的地方?
【问题讨论】:
标签: .net-core asp.net-core-3.1