I have a serverless web api built using .NET Core 3.1, EF Core 3.1 and AWS Lambda + AWS API Gateway. The API backs onto an AWS Aurora RDS backend. I am experiencing some latency (around 3 - 4 seconds) whenever EF Core needs to run this model validation step:
Microsoft.EntityFrameworkCore.Model.Validation[10400]
See below log, 5mins 51sec to 5mins 54sec as a result of this step.
2020-10-03T08:05:51.131+10:00 START RequestId: cd8375df-7f43-4983-b8c3-ad64fa378a2b Version: 3
2020-10-03T08:05:54.993+10:00 [40m[1m[33mwarn[39m[22m[49m: Microsoft.EntityFrameworkCore.Model.Validation[10400]
2020-10-03T08:05:54.994+10:00 Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data, this mode should only be enabled during development.
2020-10-03T08:05:55.048+10:00 [40m[32minfo[39m[22m[49m: Microsoft.EntityFrameworkCore.Infrastructure[10403]
2020-10-03T08:05:55.048+10:00 Entity Framework Core 3.1.4 initialized 'loyaltyContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL' with options: SensitiveDataLoggingEnabled
is there any way to turn off this model validation? And if so, what risks does it bring with it? If the risks are worthwhile I'd like to disable it to improve the performance of the API. I already keep the containers as warm as I possibly can, use provisioned concurrency to keep containers active and I use PostgreSQL connection pooling on the AWS Aurora RDS backend to re-use connections as much as possible but every so often I still hit a 'fresh' EF Core connection which executes this step. When the connection is re-used, the latency is very low and I'm super happy with the performance, it's only this step which sometimes brings things down.