I am working with a .NET Core 6 minimal api with a PostgreSQL 13 database. The packages I'm using are Microsoft.EntityFrameworkCore 6.0.0 and Npgsql.EntityFrameworkCore.PostgreSQL. I have things set to LogLevel.Information so that I can view the SQL queries Entity Framework Core creates as it talks to the database.
I notice that when I insert records through my endpoint that it does a series of single insert statements instead of the expected
(VALUES (<row1 values>),(<row2 values>)) format. For example, it is logging:
INSERT INTO <mytable> (<columns>) VALUES (<row1 values>);
INSERT INTO <mytable> (<columns>) VALUES (<row2 values>);
This is my code for the insert:
context.Items.AddRange(list);
await context.SaveChangesAsync();
Is there a way for it to combine all of the values into a single INSERT query?