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

Was it helpful?

Solution

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!

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top