ado.net - Generate connection string dynamically in ASP.NET MVC -


Hi I am working on the asp.net mvc project. Currently I am using Model First Approach, where I wanted to manually add a database using ADOnet model. Currently I have 4 databases and I have web. There are 4 connection strings in the config file I

It was okay so far, because I was working on the development environment. But now I need to keep my code alive and the problem is that we have 40 to 50 databases in live.

What should I do, when the user wants to connect to the specific database, then generate a dynamic connection string.

I have stored the process for that which gives the connection string and the database name. For example, if I have 4 databases named db1, db2, db3 and db4, then I need to compare it to the database collection name with my stored procedure result database name and if both are equal, then the connection to that database name Generate strings.

And I need to put it in session. Once I generate a connection string, then no need to generate a connection string again for a particular session.

Can anyone help me in this ??

EF DbContext as the name of a connection string or connection string is. Therefore there is no problem in generating any kind of connection string and supplying it on creating DdContext.

We have many tenants in our application and every tenant has a database. For each request we see what the tenant is and the settings provide a connection string for DB to the tenant's own database.

I have not worked with Ado.Net, but what I see in Google, this unit is similar to the framework (or its basis). Therefore, for your special implementation, web.config .

should be a way to provide connection string to the database reference.

Comments