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

Re-registering custom repositories should also override the default repositories for the same entity #7750

Closed
hikalkan opened this issue Feb 16, 2021 · 0 comments

Comments

@hikalkan
Copy link
Member

Assume that I wanted to unify IIdentityDbContext and IIdentityServerDbContext into IdentityServiceDbContext and also want to override the EfCoreIdentityUserRepository ().

Configuration:

context.Services.AddAbpDbContext<IdentityServiceDbContext>(options =>
{
    options.ReplaceDbContext<IIdentityDbContext>();
    options.ReplaceDbContext<IIdentityServerDbContext>();
    
    options.AddDefaultRepositories();
    options.AddRepository<IdentityUser, MyIdentityUserRepository>();
});

Overriden repository:

public class MyIdentityUserRepository : EfCoreIdentityUserRepository
{
    public MyIdentityUserRepository(IDbContextProvider<IIdentityDbContext> dbContextProvider)
        : base(dbContextProvider)
    {
        
    }
}

When I inject IIdentityUserRepository, I get the MyIdentityUserRepository, no problem. But, if I inject IRepository<IdentityUser, Guid>, currently I get EfCoreIdentityUserRepository. With this enhancement, I will get MyIdentityUserRepositor even in this usage.

This is very advanced scenario and most of the people will not be interested in :)

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

No branches or pull requests

1 participant