使用EF代码优先 - 标准方法种子DB,然后使用? [英] Enums with EF code-first - standard method to seeding DB and then using?
问题描述
然而,我想要能够定义枚举,并且枚举值也被种子使用数据库初始化器进入数据库。在定义枚举并创建包装器时似乎没有太多的意义,如果我必须从枚举中手动种植数据库表。
Microsoft Entity Framework 2011年6月CTP引入了新的运行时和设计时功能。以下是一些新的运行时功能:
- 实体框架中现在可以使用枚举数据类型。您可以使用Visual Studio中的实体设计器来模拟具有枚举属性的实体,或者使用代码优先工作流来定义具有枚举对象作为属性的实体。您可以像任何其他标量属性一样使用您的枚举属性,例如LINQ查询和更新...
有几个新的Visual Studio中的实体框架设计器的功能:
- 实体设计器现在支持创建枚举,空间数据类型和表值设计器功能 ...
Is there a standard way to using Enums in EF code-first? There seems to be some examples making use of a wrapper class for the enum.
However, I would like to be able to define the enum and have the enum values also seeded into the database using the database initializer. There doesn't seem to be much point in defining the enum and creating a wrapper, if I then have to seed the database table manually from the enum.
Now supported : http://blogs.msdn.com/b/adonet/archive/2011/06/30/announcing-the-microsoft-entity-framework-june-2011-ctp.aspx
The Microsoft Entity Framework June 2011 CTP introduces both new runtime and design-time features. Here are some of the new runtime features:
- The Enum data-type is now available in the Entity Framework. You can use either the Entity Designer within Visual Studio to model entities that have Enum properties, or use the Code First workflow to define entities that have Enum objects as properties. You can use your Enum property just like any other scalar property, such as in LINQ queries and updates...
There are several new features for the Entity Framework Designer within Visual Studio:
- The Entity Designer now supports creation of Enums, spatial data-types and table-value functions from the designer surface...
这篇关于使用EF代码优先 - 标准方法种子DB,然后使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!