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

Allow a DbContext to have a derived service implementation registered #28

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Meberem
Copy link

@Meberem Meberem commented Apr 9, 2020

AddAppDbContext in ef core has an overload allowing a developer to specify a "Service Type" and an "Implementation Type" for a DbContext. This allows you to have a base type in a Domain project and a particular implementation in a different project. This pull request is based on the ef core code here: https://github.com/dotnet/efcore/blob/c69926a8cdd05f4427e89ac8bac734e490b3d23a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs#L351

The result is that I can now do this in my Startup.cs

services.AddDbContextFactory<AppDbContext, SqlServerAppDbContext>();

I don't know what you would like to do about Tests for this, as I didn't want to disrupt the existing setup.

@vany0114
Copy link
Owner

Hi @Meberem thanks for taking the time to do this! I've been very busy, so I'll try to take a look in the coming weeks, sorry about it.

@Meberem
Copy link
Author

Meberem commented Jul 21, 2020

Hey @vany0114, do you think you'll have a chance to look at this any time soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants