我一直遇到枚举不映射在实体框架 5(它支持枚举)中的问题。
当我调用results.Where(r => r.Category = LogEntry.LogCategory.ERROR)
where results is an IQueryable 时,我得到指定类型成员 LogCategory 在 LINQ to Entities 中不受支持。
当我运行迁移时,Up() 方法不会映射表。
我的模型看起来像这样
public partial class LogEntry
{
public enum HttpMethod
{
GET,
POST,
PUT,
DELETE
};
public enum LogCategory
{
PAGE_VISIT,
TRANSACTION,
AUTHENTICATION,
FAILED_AUTHENTICATION,
EXCEPTION,
INPUT_VALIDATION_ERROR,
SPECIFICATION_FAILURE,
SYSTEM,
PAGE_NOT_FOUND,
UNAUTHORIZED_ACCESS
};
public int LogId { get; set; }
//public int? UserId { get; set; }
//public virtual User user { get; set; }
//public int? ForumId { get; set; }
//public virtual Forum forum { get; set; }
public DateTime DateTime { get; set; }
public string IPAddress { get; set; }
public string ActiveRole { get; set; }
public string Title { get; set; }
public string Details { get; set; }
public LogCategory Category { get; set; }
public String Url { get; set; }
public HttpMethod Method { get; set; }
public Boolean IsAjaxRequest { get; set; }
public String UserAgent { get; set; }
}
任何人有任何想法是什么问题?