Entity Framework 4.2 enum support

谁说我不能喝 提交于 2019-12-23 10:06:16

问题


Does EF 4.2 Code First have support for enum types? If so, how do you use it? The following does not create a field for the enum property when using the Nuget EntityFramework package.

public class FooContext : DbContext
{
    public IDbSet<Foo> Foos { get; set; } 
}

public class Foo
{
   public int Id { get; set; }
   public string Name { get; set; }
   public Category Category { get; set; }
}

public enum Category {One, Two, Three }

var db = new FooContext();
db.Foos.ToList();

回答1:


EF team has changed versioning so EFv4.2 is not final release of June 2011 CTP. Features from June 2011 CTP should be released as part of .NET Framework 4.5.




回答2:


No.

The enum support and many more features were included in the "June 2011 CTP" preview (see announcement) - but those require changes to the EF core and those will be shipped later.

EF 4.2 is only a few bugfixes and smaller changes - see ADO.NET team blog announcement.

What’s Not in This Release?

As covered earlier this release is just a small update to the DbContext & Code First runtime. The features that were included in EF June 2011 CTP require changes to the Core Entity Framework Libraries that are part of the .NET Framework and will ship at a later date.



来源:https://stackoverflow.com/questions/7977337/entity-framework-4-2-enum-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!