Quantcast
Channel: URF - Unit of Work & (extensible/generic) Repositories Framework
Viewing all articles
Browse latest Browse all 1539

New Post: Multiple Entity Framework Contexts(Multiple database types) on the same time.

$
0
0
Hi Danilo,

I am having the same issue, I have a prototype with Northwind and Adventure works together.

Here is my UnityConfig.
        container.RegisterType<IRepositoryProvider, RepositoryProvider>(
            new PerRequestLifetimeManager(),
            new InjectionConstructor(new object[] { new RepositoryFactories() })
        );

        container.RegisterType<IUnitOfWorkAsync, UnitOfWork>(new PerRequestLifetimeManager());

        // Northwind
        container.RegisterInstance(new NorthwindContext());

        container.RegisterType<IDataContextAsync, NorthwindContext>(new PerRequestLifetimeManager());

        container.RegisterType<IRepositoryAsync<Customer>, Repository<Customer>>();
        container.RegisterType<IRepositoryAsync<Product>, Repository<Product>>();
        container.RegisterType<IRepositoryAsync<Order>, Repository<Order>>();

        container.RegisterType<ICustomerService, CustomerService>();
        container.RegisterType<IProductService, ProductService>();
        container.RegisterType<IOrderService, OrderService>();

        // Adventure Works
        container.RegisterInstance(new AdventureWorksContext());

        container.RegisterType<IDataContextAsync, AdventureWorksContext>(new PerRequestLifetimeManager());

        container.RegisterType<IRepositoryAsync<Address>, Repository<Address>>();
        container.RegisterType<IRepositoryAsync<Person>, Repository<Person>>();

        container.RegisterType<IPersonService, PersonService>();
        container.RegisterType<IAddressService, AddressService>(); 
Can you please post your UnityConfig, so we can see how you resolve your issue.

Thanks!!!

Viewing all articles
Browse latest Browse all 1539

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>