1

I am inserting a row into a table via EF 6.0. The table in question has several million rows. Is there a way to prevent EF doing a read after an insert. I.E to prevent EF from getting the ID of the new row inserted, because in this case i do not need it and it is expensive because of all the data in the table.

MicroMan
  • 1,988
  • 4
  • 32
  • 58
  • 1
    It should be reading SCOPE_IDENTITY() for SQL Server identity column. If its guid() or something you set, no need to do the read either. http://stackoverflow.com/questions/5212751/how-can-i-get-id-of-inserted-entity-in-entity-framework – Steve Greene Aug 12 '15 at 18:36
  • What is your code for inserting a row? If you're using DbSet, you just do: dbSet.Attach(entity); dbContext.Entry(entity).State = EntityState.Added; – codeMonkey Aug 12 '15 at 18:41

0 Answers0