CLR detected an invalid program with Entity Framework

I am extracting data from a wordpress database that defines the primary key as decimal , and I am using the x64 configuration in the project ...

I was looking for a bit, I found out that this is a problem, but I could not find a solution.

What do I need to do / load in order to use decimal as a primary key?

This problem is in Microsoft Connect.

+2
c # 64bit clr entity-framework invalidprogramexception
Mar 30 2018-11-11T00:
source share
4 answers

If you are only reading data from a table, you can try creating a view that returns a field in int, and then maps your entity to the view.

In addition, I think you are very unlucky. This is a bug in the Entity Framework; either change the field type, disconnect from EF, or wait until MS corrects the error.

0
Mar 30 '11 at 2:00
source share

I had the same problem and solved it today by setting these two parameters to false in the DBContext object:

 this.ContextOptions.LazyLoadingEnabled = false; this.ContextOptions.ProxyCreationEnabled = false; 

This seems to be a serialization issue with proxy creation.

I tried to first match my types with Int32 in the EDMX file, but this gave me very low rates.

+1
Nov 15 '11 at 10:22
source share

Have you tried Entity Framework 4.1 Release Candidate? The error was marked as fixed a month or so ago.

0
Mar 30 2018-11-11T00:
source share

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

The only workaround so far has been to change all decimal primary keys to Int64. This, of course, is a change in the database schema that you did not want. Another option is to use a 32-bit environment, this error is present only in the 64-bit version.

PJ comment (11.11.2011 at 11:46) on https://connect.microsoft.com/VisualStudio/feedback/details/620031/invalidprogramexception-using-entityframework-poco-template-table-w-decimal-primary-key not seems promising at all, maybe this isn't even fixed in .NET 4.5

0
Oct 08
source share



All Articles