简体   繁体   中英

Single ASP.NET MVC application using multiple databases

I would like to build an application that connects to multiple databases.

A customer would have an address to access your application (eg customer1.myproduct.com) and then this application accesses the database "customer1." Each customer would have their own database.

What better way to make these connections? What care should I take to have a good application performance?

There is nothing to stop you from having an ASP.NET app accessing multiple databases, in the web.config of the solution you can add multiple connection strings. In the tag.

<connectionStrings>
    <add name="DefaultConnection" .....>
    <add name="EmployeeConnection" .....>
 </connectionString>

If I was you I would you use the "ADO.NET Entity model" with "Linq" to access the data, for good application performance it all depends on what you are doing, how much of it and for how long. Best to check around when you get stuck or read up on some of the best practice on http://msdn.microsoft.com

Hope this helps.

that's a bad idea to have a database for each customer. how will you be handling creation of new database for each customer manually?

maintaining all these connections will not be an easy job.

You can change the config file in the project or create new. I think you can change in config file only connectionString and it will be enough. When you want to change database you only change in:

<connectionStrings>
  ...
  connectionString="new connectionstring"
  ...
</connectionStrings>

Should be create small application for chage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM