【发布时间】:2014-11-25 11:14:00
【问题描述】:
我创建了一个模型类 Employee
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).
【问题讨论】:
-
您必须更新数据库。 msdn.microsoft.com/en-us/data/jj591621.aspx 在包管理器控制台中:更新数据库(您必须先启用迁移)
-
我是新人,请您解释一下如何
-
查看我发布的链接。 1) 工具 -> 库包管理器 -> 包管理器控制台 2) 如果未启用迁移 => 在包管理器控制台中运行“Enable-Migrations”命令 3) 在同一控制台中“更新数据库 -v”
标签: asp.net sql-server-2012 asp.net-mvc-5