dotnet / dotnet/EntityFramework.Docs

Avoiding ServiceProvider rebuild with ConfigureWarnings

Open
#2,210 8 comments 0 reactions 0 assignees View on GitHub
area-context-management
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

The documentation is warning about the possibility that the service provider will be rebuild. But it doesn't show, how to avoid it.

When using `OnConfiguring`, is it rebuilded on every Context initialization? How can I configure it globaly?

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
//... Tenant specific configuration not shown

// Globaly supress ByteIdentityColumnWarning
// Performance Warning: https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontextoptionsbuilder.configurewarnings?view=efcore-3.1
optionsBuilder.ConfigureWarnings(e => e.Ignore(SqlServerEventId.ByteIdentityColumnWarning));
}
---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 96dacb17-7fce-1e8c-2722-25de729c0811
* Version Independent ID: b9d51491-c6f0-b258-812a-8bd75577e437
* Content: [DbContextOptionsBuilder.ConfigureWarnings Method (Microsoft.EntityFrameworkCore)](https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontextoptionsbuilder.configurewarnings?view=efcore-3.1)
* Content Source: [dotnet/xml/Microsoft.EntityFrameworkCore/DbContextOptionsBuilder.xml](https://github.com/aspnet/EntityFramework.ApiDocs/blob/live/dotnet/xml/Microsoft.EntityFrameworkCore/DbContextOptionsBuilder.xml)
* Product: **entity-framework-core**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **divega**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.