DbContext falla con PrimitiveType! = error nulo

Using Entity Framework Code First, the web application crashes on a call to DbContext with the following error:

Assertion failed

Expression: primitiveType != null

Description: Assertion failed: primitiveType != null

It crashes on the following line of code:

public class MyDb : DbContext {

que es llamado por:

MyDb _db = new MyDb();

So it seams like calling DbContext generates a fatal error. DbContext is an EF function and I cannot debug inside EntityFramework.dll

preguntado el 03 de mayo de 12 a las 12:05

Check the line of code where it fails, an assertion can't fail on the class definition. -

Did you ever manage to resolve this issue? I just installed VS2012 and now one of my sites is having the same problem. -

Did you manage to resolve this issue? I'm having the same issue. Thanks, Koen -

nope sorry. it was project I temporarily jumped in. But I check out the code tomorrow to see if it's fixed (and what fixed it) -

Sorry, not fixed yet. But it's a problem related to my PC, because it works on an other developer's PC and in production -

4 Respuestas

It's a problem related to older versions of EntityFramework. It happens sometimes when copying a Visual Studio Project to a different machine. This can cause the application to calculate a different ModelHash than the one that is in the database (inside the EdmMetaData table). Solution is to delete the EdmMetaData table and use DbDatabase.SetInitializer<MyContext>( new DropCreateDatabaseIfModelChanges<MyContext>()); to put it back in place, or even better: Upgrade to a newer version of EntityFramework that is not utilizing the EdmMetaData table and ModelHashes.

Respondido 08 Oct 12, 13:10

After installing asp.net4.5 I have same error. The Answer for me is to update Entity Framework to new version.

Deleting "EdmMetaData" table didn't resolve the error.

Respondido 23 Oct 12, 13:10

I swicth to linq to sql and dint get this error. Dont know what entities is doing to cause this.

Respondido el 19 de junio de 12 a las 19:06

You need to update your EntityFramework version

respondido 03 mar '16, 13:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.