urfnet / URF.Core

Unit of Work & Repositories Framework - .NET Core, NET Standard, Entity Framework Core. 100% extensible & lightweight.
https://github.com/urfnet
MIT License
309 stars 62 forks source link

support for multiple context #52

Closed svachha closed 5 years ago

svachha commented 5 years ago

how to use this framework when you have multiple database to target in same project.

Repository takes Dbcontext but only the last DI registration will be used.

Ex. services.AddScoped<DbContext, AContext>(); services.AddScoped<DbContext, BContext>(); services.AddScoped<IUnitOfWork, UnitOfWork>(); service.AddScoped<IRepository,Repository(); only BContext will be resolved

any help appriciated.

aliBordbar1992 commented 5 years ago

any updates on this one?

tonysneed commented 5 years ago

@aliBordbar1992 This article offers a good solution to the problem of resolving multiple implementations: http://hamidmosalla.com/2018/06/30/dependency-injection-conditional-resolving-of-multiple-implementation-of-interface/

tonysneed commented 5 years ago

@aliBordbar1992 @svachha I completed a sample with all the needed code for using multiple DbContexts with URF.Core. Check it out: https://github.com/urfnet/URF.Core.Sample.MultiContext.

lelong37 commented 5 years ago

Thanks @tonysneed , awesome implementation, closing this issue.