Visual Studio, Entity Framework (EF)

Visual Studio, Entity Framework or EF 4.5

EF error 6.0

Visual Studio 2013


Object reference not set to an instance of an object.

An exception of type ‘System.NullReferenceException’ occurred

Web page error:

System.NullReferenceException was unhandled by user code

Message=Object reference not set to an instance of an object.



at System.Data.EntityKey.AddHashValue(Int32 hashCode, Object keyValue)


The IQueryable query string is valid and returns results, but EF throws and exception anyway when you call ToList().

You can copy the query to SQL Server Management Studio and execute the query successfully.

This can occur if one of your class variables of type “string” has a null value in the query response.

For more information about how Acumen can help with your other Software needs, contact us today!

For additional help, feel free to click on Microsoft’s Support page below: