Posted by: lluppes | September 15, 2012

MVC3 Application Failing after ASP.NET 4.5 Install?

I have an existing MVC3 application on my production server that has been out there for a long time and hasn’t really changed.  Recently, we started putting MVC4 applications on our server, so we installed ASP.NET 4.5 on that server.  The old MVC3 application hadn’t been used in a while (and of course we didn’t test this one when we upgraded!), but after the upgrade, it began getting this error:

System.Diagnostics.Contracts.ContractException: Assertion failed: primitiveType != null at System.Runtime.CompilerServices.ContractHelper.TriggerFailureImplementation(ContractFailureKind kind, String displayMessage, String userMessage, String conditionText, Exception innerException) at System.Data.Entity.ModelConfiguration.Utilities.RuntimeFailureMethods.ReportFailure(ContractFailureKind contractFailureKind, String userMessage, String conditionText, Exception innerException) at System.Data.Entity.ModelConfiguration.Utilities.TypeExtensions..cctor()

I fired up VS2010 and went back into the project to see if I could replicate this error on my local machine.   Of course, the first thing I had to do was to update the project file to fix the references to System.Web.WebPages (see  Once that was fixed, when I fired up the app, I got the same error, and it was breaking on the line that created my dbContext.

After a little experimenting, I updated the Entity Framework to the latest version, and everything was fixed.  Nothing else changed, but now it works fine. Not sure of the exact details, but it would appear some of the older versions of Entity Framework are not compatible with ASP.NET 4.5.   Very strange…


Written by .



  1. I’m having this same problem; glad that you were able to resolve. Did you just update the EntityFramework reference to the newest 4.4 version in the project?

    • I just did a nuget “install-package entityframework”. I think it upgraded it the latest, which is 5.0.

What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: