我是EF5 Code First的新手,在开始工作项目之前,我正在修改概念验证.
我最初创建了一个看起来像的模型
public class Person {
public int Id { get; set; }
public string FirstName { get; set;}
public string Surname {get;set;}
public string Location {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我添加了一些记录,使用了一个我坚持在顶部的MVC应用程序.
现在我想将Location列更改为枚举,如:
public class Person {
public int Id { get; set; }
public string FirstName { get; set;}
public string Surname {get;set;}
public Locations Location {get;set;}
}
public enum Locations {
London = 1,
Edinburgh = 2,
Cardiff = 3
}
Run Code Online (Sandbox Code Playgroud)
当我添加新的迁移时,我得到:
AlterColumn("dbo.People", "Location", c => c.Int(nullable: false));
Run Code Online (Sandbox Code Playgroud)
但是当我运行update-database时出现错误 …