Why can't I insert record with foregion key in a single server request?
- by Eran Betzalel
I'm tryring to do a simple insert with foregion key, but it seems that I need to use db.SaveChanges() for every record insert. How can I manage to use only one db.SaveChanges() at the end of this program?
foreach (var file in files)
{
db.AddToFileSet(file);
db.SaveChanges();
db.AddToDirectorySet(
new GlxCustomerPhone
{
SimIdentifier = file.Name + "Dir",
CreationDate = DateTime.UtcNow,
file_relation = file
});
db.SaveChanges();
}