0
使用EntityFramework
和EntityFramework.Migrations
即可使用代码优先和自动迁移实现解决方案。使用EntityFramework.Migrations自动迁移会导致重命名错误,但不会与SqlMigrations一起使用
无论我做了一个非常简单的测试解决方案来测试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
,林不知道什么即时做错了还是什么我应该做的事...
下面是资源问题,我一直在阅读有关这两个:
的最后一个Beta版本您可能想检查另一个EF Code-First迁移库[EntityFramework.SchemaCompare](http://github.com/kriasoft/data) –