Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.1.1] Warn on redundant AddEntityFramework* calls #19154

Merged
merged 1 commit into from
Dec 10, 2019

Conversation

AndriySvyryd
Copy link
Member

Fixes #19053

Description

EF provides AddEntityFramework* methods to add EF-required services to a service collection, but this call is usually not needed when AddDbContext is called and is completely unnecessary if UseInternalProvider isn't called for the DbContext options.

This change adds a warning that is logged when this case is detected.

Customer Impact

By calling AddEntityFramework* on the application service collection the customer can inadvertently make other frameworks use EF services like IMemoryCache which can lead to hard-to-diagnose issues at runtime.

How found

Customer-reported

Test coverage

We had tests for this scenario, but didn't consider it to be common enough to warrant a warning.

Regression?

Yes, in 3.0.0 EF started registering IMemoryCache with a hard limit.

Risk

Low, no behavior change

@ajcvickers ajcvickers modified the milestones: 3.1.2, 3.1.x Dec 5, 2019
@ajcvickers
Copy link
Contributor

@AndriySvyryd Can you check on the build failure here?

@AndriySvyryd
Copy link
Member Author

It's just an infrastructure issue

@ajcvickers
Copy link
Contributor

ajcvickers commented Dec 10, 2019

@AndriySvyryd This is approved for 3.1.1 servicing. Please merge ASAP.

@ajcvickers ajcvickers changed the title [3.1.2] Warn on redundant AddEntityFramework* calls [3.1.1] Warn on redundant AddEntityFramework* calls Dec 10, 2019
@ajcvickers ajcvickers removed this from the 3.1.x milestone Dec 10, 2019
@AndriySvyryd AndriySvyryd merged commit b0da3eb into release/3.1 Dec 10, 2019
@AndriySvyryd AndriySvyryd deleted the Issue19053 branch December 10, 2019 19:13
@jamshedd jamshedd added this to the 3.1.1 milestone Dec 10, 2019
@jamshedd
Copy link
Member

Approved for 3.1.1

@ajcvickers ajcvickers removed this from the 3.1.1 milestone Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants