9

Just trying to confirm an impression: it seems enums in EF5 + Code First are only supported when declared within the same namespace as the classes using them as property types.

Can anyone confirm that? Couldn't find anything on the web for this...

1
  • EF5 and Code First should work. If they are not let me know. Full disclosure - there is a bug in this area but it is for enums defined in a separate assembly - entityframework.codeplex.com/workitem/532 Commented Nov 25, 2012 at 7:10

2 Answers 2

1

A relevant bug that was fixed earlier. 4.3 Beta 1 release notes say:

Bug fix for GetDatabaseValues. In earlier releases this method would fail if your entity classes and context were in different namespaces. This issue is now fixed and the classes don’t need to be in the same namespace to use GetDatabaseValues.

My guess is that GetDatabaseValues function is still buggy for this occasion (but that's just an educated guess). You may want to report this here: ADO.NET team blog: EF5 Beta 1 Available

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

Comments

0

Not only do your enumerations have to be in the same namespace to be supported by EF5 Code First, they have to be in the same class file as your POCO Model.

1 Comment

This is incorrect. I've been playing with EF5 Code First this week and my primary model has two properties that are Enums, both in separate files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.