Enum Support for Entity Framework Database First

.net .net-4.5 edmx entity-framework enums

Question

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

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

Can anyone explain to me or provide me with some instructions on how to properly implement enum support for database first applications. I'd imagine I'd have to start in the edmx designer and right click one of my columns in the tables and convert to enum? Thanks for any advice. I'm using .NET 4.5 and Enity Framework 5.0

1
14
7/18/2013 6:47:21 PM

Accepted Answer

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!

13
7/18/2013 9:01:48 PM

Popular Answer

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.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow