【发布时间】:2019-12-10 10:54:33
【问题描述】:
.net 核心 3.0。 我有一个 LibraryProject(SyWaterStandardLibrary),有一个 DbContext。当我构建新的 WebProject(WebApplicationTestLibrary) 并使用 LibraryProject。
启动:
services.AddDbContext<LocalContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("SMS"),
optionsBuilder => optionsBuilder.MigrationsAssembly("WebApplicationTestLibrary"))
);
当我执行时:add-migration init -context localcontext
发生错误:您的目标项目“WebApplicationTestLibrary” 与您的迁移程序集“SyWaterStandardLibrary”不匹配。 更改您的目标项目或更改您的迁移程序集。
.net core 2.2 中不存在此异常。 请问有什么问题。
【问题讨论】:
-
你检查过.net核心版本匹配吗??
-
是的。我查过了。
-
当我将启动项目和目标项目设置为
WebApplicationTestLibrary和optionsBuilder => optionsBuilder.MigrationsAssembly("SyWaterStandardLibrary"))时,我得到了同样的错误,还有一个建议是用WebApplicationTestLibrary更改你的迁移程序集来解决问题 。确保启动项目、目标项目和 migrationsAssembly 相同。
标签: c# asp.net-core entity-framework-core