我使用EF 5.0代码首先,在.NET 4库中。尝试将类成员设置为Enum
类型,但它不会持久保存到数据库,并且EF在基于代码创建数据库时不会发生运行时异常。枚举类型未映射到数据库表
当然,当我尝试查询针对枚举:
var departments = db.Departments
.Where(dep => dep.Name == DepartmentNames.English);
我得到一个异常说:
The specified type member 'Name' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
我使用的是枚举使用微软的例子:http://msdn.microsoft.com/en-us/data/hh859576.aspx
Enum成员是否还不支持?当使用.NET 4环境托管时,EF 5.0与使用.NET 5环境托管时有所不同吗?