EF5 Code First Enums and Lookup Tables

后端 未结 6 1745
南笙
南笙 2020-11-27 05:35

I\'d like to define an enum for EF5 to use, and a corresponding lookup table. I know EF5 now supports enums, but out-of-the-box, it seems it only supports this at the objec

6条回答
  •  情书的邮戳
    2020-11-27 05:45

    I have created a package for it

    https://www.nuget.org/packages/SSW.Data.EF.Enums/1.0.0

    Use

    EnumTableGenerator.Run("your object context", "assembly that contains enums");
    

    "your object context" - is your EntityFramework DbContext "assembly that contains enums" - an assembly that contains your enums

    Call EnumTableGenerator.Run as part of your seed function. This will create tables in sql server for each Enum and populate it with correct data.

提交回复
热议问题