I have a lot of inserts that are just for log purposes on an Azure DB, and I see that now most of the DTU usage is taken by this logging.
The load of the database is not because of the insert itself, but because after insert, but because the CreationDate field is being generated by the database and EFCore selects it after the insert.
In order to solve the "datetime2" error conversion, I have defined the CreationDate field as entity.Property(e => e.CreationDate).HasColumnType("datetime").HasDefaultValueSql("getdate()");
So EF calls the DB after insert:
(@p0 uniqueidentifier)SELECT [CreationDate]
FROM [MyLogs]
WHERE @@ROWCOUNT = 1 AND [Id] = @p0
Is there a way to avoid this behavior, and just let the entity not tracked after insert?
For now the only way I see is to ignore the CreationDate field from the entity model as it is not used. entity.Ignore(e => e.CreationDate);