Tuesday, October 14, 2008

Tip #1: Understanding Cryptic MVC Errors

Some who try to use the Entity Framework with MVC may encounter the following error:

CompileError

If you can see it the error reads:
CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

I spent a good deal of time trying to add this reference to the View. However, for some reason despite I had the assembly in my Reference folder in the Project, it was not in the web.config.  Add the following line to the web.config:

<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

Once you add this and rebuild, the error should go away.

9 comments:

snowman said...

Thanks, this solved my problem.

jabbasoft said...

Thankyou! fixed me too

Anonymous said...

You just saved me hours. Thanks!

Anonymous said...

Thanks!

Anonymous said...

Thanks mate, good call.

oo said...

Spend hours chasing this one :( Thanx mate!

Anonymous said...

thanks..solved my problem

Томислав Марковски said...

I love you!

Anonymous said...

coool !! thanks !!!