开发者

CLR detected an invalid program with Entity Framework

I am retrieving data from a wordpress database which defines the primary key as decimal and I am using a x64 configuration on the project...

开发者_运维百科

The bit I searched I found out that it is the problem, but I couldn't find a solution.

What do I have to do/download to be able to use decimal as a primary key?

This issue on Microsoft Connect


I had the same problem and I solved it today by putting those two options to false in the DBContext object:

this.ContextOptions.LazyLoadingEnabled = false;

this.ContextOptions.ProxyCreationEnabled = false;

It seems to be a serialization problem with the proxy creation.

I tried first to map my types to Int32 in the EDMX file but this gave me very low performances.


If you're only reading data from the table you can try creating a view that casts the field to an int and then map your entity to the view.

Beyond that, I think you're pretty much out of luck. This is a bug in Entity Framework; either change the field type, switch away from EF, or wait for MS to fix the bug.


Have you tried the Entity Framework 4.1 Release Candidate? The bug was marked as fixed as month or so back.


I ran into the same problem, and sad to say: it is still not fixed by Microsoft. I tried EF 4.1 and EF 5.0, but they do not contain any fix for this problem.

The only workaround so far was to change all decimal primary keys to Int64. That, of course, is a change in DB schema, which is not what you wanted. The other option is to use 32 bit environment, that bug is present in 64 bit only.

The comment by PJ (on 11/11/2011 at 11:46 AM ) on https://connect.microsoft.com/VisualStudio/feedback/details/620031/invalidprogramexception-using-entityframework-poco-template-table-w-decimal-primary-key does not sound promising at all, maybe it's not even fixed in .NET 4.5

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜