Using multiple databases within one application

后端 未结 2 1230
傲寒
傲寒 2021-01-16 06:37

I have a web application made for several groups of people not connected with each other. Instead of using one database for all of them, I\'m thinking about making separate

相关标签:
2条回答
  • 2021-01-16 06:57

    "my classes are explicitly connected with the databases"

    The key to answering your question rests with what you mean by this. If you've hardcoded your application somehow to rely on one specific database, and all your objects are hardcoded to create their own datacontexts using the same connection string, then you've got a lot of refactoring to do.

    If you've centralized your DataContext creation using a Repository Pattern, then it wouldn't be more than a few lines of code to conditionally create a DataContext for one database or the other and pass it to your objects.

    So it all comes down to how you implemented your contexts.

    0 讨论(0)
  • 2021-01-16 07:03

    If the database schemas are the same simply changing the connection string for each database would suffice. You don't necessarily need to create different contexts.

    Your other problems are probably solved by reviewing the existing answers for multi-tenancy Asp.NET MVC questions already on Stack Overflow.

    0 讨论(0)
提交回复
热议问题