繁体   English   中英

在程序集“ForApi”中发现了一种以上的迁移配置类型。 指定要使用的名称

[英]More than one migrations configuration type was found in the assembly 'ForApi'. Specify the name of the one to use

我第一次进行了迁移,它可以工作,但是当我打开我的项目时,它会显示类似这样的内容。 我做了几天同样的迁移。

System.Data.Entity.Migrations.Infrastructure.AutomaticMigrationsDisabledException:'无法更新数据库以匹配当前的 model,因为存在未决的更改并且自动迁移被禁用。 将挂起的 model 更改写入基于代码的迁移或启用自动迁移。 将 DbMigrationsConfiguration.AutomaticMigrationsEnabled 设置为 true 以启用自动迁移。

当我再次尝试更新数据库时,在 package 管理器控制台中显示类似的内容

无法更新数据库以匹配当前的 model,因为存在待定更改并且禁用了自动迁移。 将挂起的 model 更改写入基于代码的迁移或启用自动迁移。 将 DbMigrationsConfiguration.AutomaticMigrationsEnabled 设置为 true 以启用自动迁移。 您可以使用 Add-Migration 命令将挂起的 model 更改写入基于代码的迁移。 Package 经理控制台

您已经创建了配置,因此您必须指定配置名称。

add-migration -ConfigurationTypeName BaseConfiguration(this is your config name)

还可以考虑使用 CLI https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/providers?tabs=dotnet-core-cli

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM