1
我的应用程序是MVC 5.2,首先使用EF 6.1数据库。没用过枚举之前,我试图从下拉列表存储在以下键值:EnumDropDownListFor扩展现有的数据库
public partial class Sleep {
public Nullable<int> SleepId {get;set;}
}
要采取新的@ HTML.EnumDropDownListFor的优势,我增加了以下部分类
public enum SleepValues : int
{
Good = 1,
Bad = 2,
NotWell = 3
}
并改变了原有的类
public Nullable<SleepValues > SleepId {get;set;}
我得到以下错误:
The entity type Sleep is not part of the model for the current context.
希望你的建议。
你的睡眠表在你的分贝? – Jags 2014-11-02 02:25:21
是的。它有Id,SleepId和theDay。 – hncl 2014-11-02 02:28:13
您是否将实体添加到context.Add(实体)等上下文中?什么是你的对象的EntityState? – Flaudre 2014-11-02 02:59:30