EntityKey null reference

Discussion in 'General troubleshooting' started by anderandreani, Jun 28, 2010.

  1. When I run this code:

    var newAnagrafica = e.Entity as Anagrafica;
    var idParrocchia = Convert.ToInt32(Request.QueryString["idParrocchia"]);
    EntityKey en = new EntityKey("ParrocchiaGestDbEntities.Parrocchia", "idParrocchia", idParrocchia);
    newAnagrafica.ParrocchiaResidenzaReference.EntityKey = en;

    I get this error on the last line:
    Object reference not set to an instance of an object.

    Locally everything works fine..
    Can please somebody help me?
  2. Ray


    Does your application connect to a SQL server in the back end?

    Did you upload the database and all the required objects and data to our SQL server?
  3. Yes I use Sql server and I've uploaded all I need
    By the way I found the solution!
    The error comes out when I try to insert a new record setting a date field with a not valid value (ex. 24/12/1985)
  4. Thanks for posting the follow up.

Share This Page