1

As my application is multitenant with same codebase and different databases so i need to implement logic to set dbcontext after user login. I am planning to use DI (mostly Automapper but not final) so If i want to create connectionstring once user logic then is it possible to pass connectionstring to dbcontext through DI or any other approach to set connectionstring per request to dbcontext

Thanks for support

2
  • Automapper is not a DI solution, its a mapping solution to map between types with similar structures. Maybe you meant AutoFac? Commented Sep 20, 2016 at 15:28
  • sorry not automapper but nInject or unity Commented Sep 20, 2016 at 16:07

1 Answer 1

1

If you need to implement Multi tenant and multi database kind of layered architecture,I highly recommend to see the implementation of the ASP.NET Boilerplate.It is a free and open source.

You don't need to reinvent the Wheel

It uses AutoMapper as a mapping library and Castle Windsor as a DI.

ASP.NET Boilerplate Documentation

Multi Tenancy

It supports :

  1. Single Deployment - Single Database
  2. Single Deployment - Hybrid Databases
  3. Multiple Deployment - Single/Multiple/Hybrit Database

It supports ASP.NET Core and Entity Framework Core.

Here is the latest article about it : ASP.NET Core, Entity Framework Core and ASP.NET Boilerplate

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for reply but my database already exist and it seem boilerplate using their own structure for db. we have separate database for each client mostly same.
what do you mean by boilerplate using their own structure for db ? They don't have such.you can define your own db structure as you wish.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.