使用EntityFramework自动迁移.Migrations给出重命名错误,而不是SqlMigrations
本文关键字:错误 SqlMigrations 重命名 EntityFramework 迁移 Migrations 使用 | 更新日期: 2023-09-27 18:16:36
我使用EntityFramework
和EntityFramework.Migrations
实现使用代码优先和自动迁移的解决方案。
无论我做了一个非常简单的测试解决方案来测试迁移功能,我卡住了,重命名简单的属性。
我有这个实体:
public class Customer
{
public int Id { get; set; }
public string FullName { get; set; }
public string LastName { get; set; }
}
现在当我尝试重命名FullName to FirstName
时,我知道我必须使用重命名的更新数据库,所以我在控制台中输入这个:
Update-Database -Renames:"Customer.FullName=>Customer.FirstName"
现在这曾经工作,当我使用"SqlMigrations
",但现在我使用"EntityFramework.Migrations
"它不起作用,它给了我这个错误:
Update-Database : A parameter cannot be found that matches parameter name 'Renames'.
At line:1 char:26
+ Update-Database -Renames: <<<< "Customer.FullName=>Customer.FirstName"
+ CategoryInfo : InvalidArgument: (:) [Update-Database], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,System.Data.Entity.Migrations.UpdateDatabaseComma
nd
所以我打赌EntityFramework.Migrations
是不同的,我不确定我做错了什么或我应该做什么…
以下是我一直在阅读的参考资料:
- EntityFramework。SqlMigrations
- EntityFramework。迁移
EntityFramework团队。Migration已经确认此功能已被弃用,并且它不在EntityFramework.Migrations
的最后一个beta build中