我創建了一個模型類EmployeeASP.Net MVC 5當更改類數據註釋時,它會給出異常錯誤?
public class Employee
{
public int ID { get; set; }
[DisplayName("Employee Name")]
[Required(ErrorMessage = "Employee Name Is Required") ]
public string Name { get; set; }
public int Email { get; set; }
public double Salary { get; set; }
public int Address { get; set; }
}
,當我跑的時候,我看到那場址爲int,所以我 改成了字符串,它的工作後罰款的應用程序或:
public class Employee
{
public int ID { get; set; }
[DisplayName("Employee Name")]
[Required(ErrorMessage = "Employee Name Is Required") ]
public string Name { get; set; }
public string Email { get; set; }
public double Salary { get; set; }
public string Address { get; set; }
}
時我運行應用程序,它給出了以下錯誤:
An exception of type 'System.InvalidOperationException' occurred in ProductApps.dll but was not handled in user code
Additional information: The model backing the 'ProductContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
您必須更新數據庫。 http://msdn.microsoft.com/en-us/data/jj591621.aspx在包管理器控制檯中:更新數據庫(您必須先啓用遷移) – 2014-11-25 11:18:01
我是新來的請你解釋一下 – 2014-11-25 11:26:06
請參閱鏈接,我已經發布。 1)工具 - >程序包管理器 - >程序包管理器控制檯2)如果未啓用遷移程序=>在程序包管理器控制檯中運行「啓用遷移」命令3)在同一控制檯中的「更新數據庫-v」 – 2014-11-25 11:29:29