Can anybody tell me how to bulk insert data into SQL Server under a transaction? I have a program to import data into multiple tables of a database from a file. I am using SQL Server and Entity Framework to import those records into the database under a transaction. Please tell me is it good way to follow?
I am using Entity Framework for this. But when I import 1000 records, I found it causes locks on SQL Server.
The file contains many columns. Few columns belongs to parent table and the rest of columns belongs to child tables. So how could we map them using SqlBulkCopy
?
There are 10 child tables. I need to insert data from file to child tables first. If insertion of records cause error in child table for some what reason I will have to rollback that transaction and continue with another record from file