I have an application which utilizes a webservice to get data on a regular basis, and needs to insert the records into a Sql Server database. It needs to check the table if the unique key exists or not, if it exists, the record has to be updated, it not, the record should be inserted.
I need a solution like Merge in oracle database to eliminate thinking about duplicate records, and something like bulk insert, in EF to insert all data at once.
I used AddRange and SaveChanges, but it uses several inserts and updates in DB, which takes long time to complete.
MERGEon the database (or separateINSERT/UPDATEstatements,MERGEdoesn't really add much for simple scenarios). The staging table can be made an in-memory table if you're using SQL Server 2016+, for that sweet extra performance.SqlBulkCopy), as it is the fastest way to get rows from client to server. But I don't know EF well enough. If there is no way to do it with EF it would still be worth doing without it.