How do you manage to get the same effect as SQL simple
INSERT INTO myTable VALUES (X), (Y), (Z),.....
and so on?
You may generate the query and execute the same as per the following;
Refer documentation here. Even though it is relevant to EF, it is applicable to EF Core as well
If you are using EF Core with SQL Server and has to insert a lot of entities then you can pick one of the following libs that are using SqlBulkCopy:
The usage is very easy
List<MyEntity> entities = ...; await context.BulkInsertAsync(entities);
SqlBulkCopy is the fastest way to get the entities into a SQL Server.
Please note, as with raw SQL statements the
DbContextis not aware of this operations, so some caution is required. But, if you have to insert a lot of data then there is not much choice as to use some techniques that are closer to the database.