How can I add a new entity with EF where I have Id
column which is defined as identity
in the database ?
I get the following error:
Cannot insert explicit value for identity column in table 'AppsData' when IDENTITY_INSERT is set to OFF.
But I cannot set the Id
to null, as it's an int
in the database (not even nullable)
My function is:
public Conduit.Mam.MaMDBEntityFramework.AppsData Add(Conduit.Mam.MaMDBEntityFramework.AppsData item)
{
maMdbEntities.AddToAppsDatas(item);
maMdbEntities.SaveChanges();
return item;
}