Improving bulk insert performance in Entity framework [duplicate]

There is opportunity for several improvements (if you are using DbContext): Set: yourContext.Configuration.AutoDetectChangesEnabled = false; yourContext.Configuration.ValidateOnSaveEnabled = false; Do SaveChanges() in packages of 100 inserts… or you can try with packages of 1000 items and see the changes in performance. Since during all this inserts, the context is the same and it is getting bigger, … Read more

How to fix the Hibernate “object references an unsaved transient instance – save the transient instance before flushing” error

You should include cascade=”all” (if using xml) or cascade=CascadeType.ALL (if using annotations) on your collection mapping. This happens because you have a collection in your entity, and that collection has one or more items which are not present in the database. By specifying the above options you tell hibernate to save them to the database … Read more