Enum Support for Entity Framework Database First

前端 未结 3 670
心在旅途
心在旅途 2020-12-11 01:12

I can find a bunch of tutorials on how to implement enum support for model first and code first like these:

http://msdn.microsoft.com/en-us/data/jj248772.aspx

<
相关标签:
3条回答
  • 2020-12-11 01:46

    What I wound up doing is changing the column type to int in the database then I went into the edmx and updated model from database, then I went and added a enum type and then changed the column type in the edmx designer to be of type of that enum. Reupdated the poco's and everything Works good!

    0 讨论(0)
  • 2020-12-11 01:46

    You should probably read this as well.

    Enum Types are not created in your model via Database-First actions

    • When you create an EDM from an existing database, Enums are not defined in your model.
    • Update Model from Database will preserve your declaration of Enum types, but again, will not detect Enum constructs from your database.

    I've seen a couple of solutions that use T4, but in my specific case its just adding unneeded complexity to my project. So I will give in and so the enums code-first.

    0 讨论(0)
  • 2020-12-11 01:52

    Here is my wild guess: After you generate your .edmx file from your database, you can follow the guide in the following link: http://msdn.microsoft.com/en-us/data/jj248772.aspx

    0 讨论(0)
提交回复
热议问题