【发布时间】:2017-06-07 04:38:40
【问题描述】:
public partial class Employee
{
public int Emp_Id { get; set; }
public string Emp_Name { get; set; }
public string Emp_City { get; set; }
public Nullable<int> Emp_Age { get; set; }
}
这是使用 EF 为表 Employee 生成的类。我想在应用程序中将Emp_Name 更改为EmpName 而无需更改表结构。但是使用以下更改使用数据注释dbEntity.Set<Employee>().ToList(); 获取异常
"实体类型Employee不是当前模型的一部分 上下文。”
System.InvalidOperationException。
如何解决这个问题
public partial class Employee
{
public int Emp_Id { get; set; }
[Column("Emp_Name")]
public string EmpName { get; set; }
public string Emp_City { get; set; }
public Nullable<int> Emp_Age { get; set; }
}
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4 entity-framework-6