Suppress output of OnConfiguring method in Entity Framework Core 5.0

If you’re using Entity Framework Core with the database first approach and re-scaffold you’ll see that by default EF Core will create an OnConfiguring overload with a connection string so that the context is immediately usable.

In EF Core 5.0 if you already have your connection string defined in Startup.cs -> ConfigureServices like the first image below or through some other approach you can now suppress the output of OnConfiguring in the generated DbContext class.

The relevant flag is..

-NoOnConfiguring for the package manager console
–no-onConfiguring for the CLI approach

Suppress OnConfiguring in Entity Framework

Leave a Reply

Your email address will not be published. Required fields are marked *