Reputation: 2965
I have two SQL databases, in this example one is named "Database_Core", one named "Database_Test".
When I am developing my ASP.Net app I want to target "Database_Test". After the app has been published it needs to target "Database_Core" so that the Users can access the "real" data.
Moving forward this may expand as we may have multiple clients that target their own version of a SQL database, keeping their data separated from all other clients. Currently I create a context like so;
services.AddDbContext<DashboardContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("Database_Core")));
The ConnectionString is stored in appsettings.json
. In previous apps (WPF) I have had a small SQLLite
file that exists on each User's PC that defines which database to target.
The issue now is that moving onto ASP.Net Core
and a new web app, this method is not feasible as I simply will not have access to each User's machine.
I will be using SSDT to ensure that the Database schema is consistent across all Client Databases.
My question is, how can I maintain a Database for each client but only have one app, so that when Users enter the app their specific Database is targeted?
Upvotes: 1
Views: 1255
Reputation: 21607
I wouldn't use the same Application to serve more than one site, you not only have the database but also security data and cache in the middle, and you won't want to mess that up.
What you could do is:
Upvotes: 1