I am trying to create a record in the db that has a predefined primary key value. I know how to do this with sql, but I was wondering if EF can do this for me? Otherwise, I will have to create a stored proc for the inserts.
This is the query:...using (var db = new AppDbContext())
{
var item = new IdentityItem {Id = 418, Name = "Abrahadabra" };
db.IdentityItems.Add(item);
db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Test.Items ON;");
db.SaveChanges();
}
...
I am using ASP.NET Boilerplate template....I want to update ...Details... table, which contains more than one item. If an item exists, it must update, otherwise a new one must be added and all other entries relating to ...Master... primary key in ...Detai...