I need to add many entities at once. This is not complex:
EntityType entities = GetEntities();
dbContext.MyTable.AddRange(entities);
However each entity references another sub property (that is already existing, and for which I know the id). Is there an efficient way to avoid querying in advance all the subproperties?
for (int i = 0; i < entities.Length; i++)
{
// adding already existing property
entities[i].MyProperty = new MyProperty { Id = ExternalIds[i] };
}
dbContext.MyTable.AddRange(entities); // Don't want to create new entities