Is it just me or does this not seem to work?
In model first I dragged in a simple table and created an enum (via convert to enum). Now I've tried with and without creating the enum items in the dialog, but if I tick the reference external type I get:
Schema specified is not valid. Errors: No corresponding object layer type could be found for the conceptual type 'ControlPanelDevModel.EventType'.
Ok as a supplement to the above I found I've been getting the same error when the mapping an external Enum to database type of tinyint.
The solution is to have your Enum inherit from type "byte" as specified in this post.
Tinyint(byte),SmallInt(Int16) not compatible with Enum in EF5
Take a look at my blogpost - it shows how to create and use external enum types: http://blog.3d-logic.com/2012/09/11/using-exisiting-enum-types-in-entity-framework-5/ If you are using EF5 RTM (and not EF June CTP 2011) shipped with .NET Framework 4.5 you don't need to specify members of the EDM Enum Type. The important thing is to make sure that the EDM Enum Type name match the name of the external CLR enum type and that the underlying types are the same (if no underlying type is specified Edm.Int32 will be used - similarly to C#/VB.NET - where int is used). If you decide to sepcify members on the EDM Enum Type you must not have a member whose name and/or value is different from the C#/VB enum type members. You also don't have to specify all the members of the CLR enum type in the EDM enum type (in fact, as I pointed above, you may not have any members as you did and everything is supposed to work).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With