1

I am using an existing DB (I cannot change it). My class maps to a column of type numeric(18,0). If I try to map this to anything else, it breaks and tells me to map to Decimal. I've also googled and confirmed this is the right type (and tried using Int64, etc, and been told to use Decimal). When I use Decimal, I get this error:

Common Language Runtime detected an invalid program.

So, it appears that I can't map to this column. I am mapping to a view, could I perhaps return this value as a string from my view? Do I need to? Is the value just too big and there's no way to map it?

Eranga
  • 32,181
  • 5
  • 97
  • 96
cgraus
  • 784
  • 2
  • 9
  • 26
  • Some code would probably help. – M.Babcock Jan 19 '12 at 04:05
  • is the program running in 32 bit mode or 64 bit mode? what about the target environment (32 bit or 64 bit)? finally is this an ASP.NET application? – Skyrim Jan 19 '12 at 04:10
  • I am running on a 64 bit computer, and it's an MVC application. I'm surprised that things like that would change how Entity Framework works. There is no code to post, apart from [Key] [Column("SERIAL_NUM")] public virtual Decimal SerialNumber { get; set; } and I've told you the type that it is in the DB. – cgraus Jan 19 '12 at 04:21

2 Answers2

2

Looks like this is a reported bug fixed in .NET vNext: https://connect.microsoft.com/VisualStudio/feedback/details/620031/invalidprogramexception-using-entityframework-poco-template-table-w-decimal-primary-key

Also, see here: InvalidProgramException: Common Language Runtime detected an invalid program

and

CLR detected an Invalid Program

Community
  • 1
  • 1
Chris Shain
  • 50,833
  • 6
  • 93
  • 125
  • looks like you are right. I am running Windows 7 64 bit, so I guess 64 bit is the issue. I've converted it to a string, which is not great, but it's working. Thanks – cgraus Jan 19 '12 at 05:48
0

Have you installed Sql Server Compact on your computer your running the application on? If you are running a 64 bit machine, make sure you install the Sql Server Compact 64 bit version.

Skyrim
  • 865
  • 5
  • 6