我想了解迁移 . 我有AutomaticMigrationsEnabled = true;并创建了初始迁移 .
如果我向DBContext添加新的DBSet并发布此服务,则使用相应的新表作为可疑数据库更新数据库 .
但是,如果我更改实体类中的属性的数据类型,例如在下面的示例中将StatusID从int更改为字符串并发布服务,则相应的列数据类型不会在数据库中更新 .
如果AutomaticMigrationsEnabled = true,那么为什么在这种情况下数据库不会自动更新?
谢谢
namespace myService.DataObjects
{
public class Status : EntityData
{
public int StatusID { get; set; }
public string Description { get; set; }
}
}
public class myServiceContext : DbContext
{....
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
SetSqlGenerator("System.Data.SqlClient", new EntityTableSqlGenerator());
}
1 回答
它现在正在为我工作,我不确定我是在看过去的事情还是什么,但我会将此标记为已回答 . 感谢您花在这上面的任何时间