Using Enums with Code First & Entity Framework 5

孤者浪人 提交于 2019-12-06 21:21:27

问题


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:


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




回答2:


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.



来源:https://stackoverflow.com/questions/9769619/using-enums-with-code-first-entity-framework-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!