6

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'.

2 Answers 2

12

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

Sign up to request clarification or add additional context in comments.

Comments

10

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).

1 Comment

Thanks for that! I'll have to keep this in mind for my next development... Unfortunately i'm gonna have to revert to ef 4.4 as my client has no intention of upgrading there servers to 2008r2.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.