I have a client and they want a new feature. There are currently multiple api’s we can use, but it’s too expensive (like 2k a year). He asked me to create the api, which is very easy, because once a year a few new rows should be added. The problem is how should I insert a lot of data in the database (like 10k rows static data)

It is possible to provide the seeds in the modelBuilder HasData, but it takes too much time because I need to set the relations between multiple tables with the foreign key etc.. a small mistake caused me yesterday to figure it out for multiple hours.

I was thinking of making CRUD operations to insert the data in the database, but I’m afraid of losing the data. Seeds are always in my .cs file which cant be lost but a small mistake in my production db can cause to erase the rows. Has anyone suggestions about dealing with this?
I tend to eschew ORMs for these kind of problems and just use the SqlBulkCopy class to dump all the rows into the database as quickly as I can.
Hmm didnt know about this. Thanks I will look at it

EF has a BulkInsert extension that I use at work. Forgot the name of it, but works great. Google for EF6 bulk insert.
Bulkextensions
Use bulkcopy. It took around 2-5 sec to insert 1 million records.

source