Converting Single DB ASP.NET Site into MultiTenant - Membership and Roles Dilemma

杀马特。学长 韩版系。学妹 提交于 2019-12-22 11:13:13

问题


I'm in the process up changing a single SQL DB website (ASP.NET/VB.NET) into a multitenant app, where each client has their own database.

In the old site, all the ASP roles, logins and providers pointed to the single database.

Now we have multiple databases, I'm wondering what would the best architecture/techniques to use. There is one database that configures the tenants, such as the company name, various settings (that would normally be in a web.config) and the connection string to their tenant database.

Should we have all the membership & role stuff in the single database that configures the tenants or do we have membership & roles in each individual tenants database? Option 2 seems tricky because I think ASP.NET only likes one set of RoleProviders defined in the web.config.

Has anyone tried this before or got any recommendations?


回答1:


If you're using the ASP.Net Membership model with the built-in providers' then putting them into one DB is the easiest as you indicated.

One option, and I've not tried this, is to define in your web.config file a provider for each tenant. This would allow each tenant to have their own membership db, and allow you to avoid username collisions between the tenants (if this is a requirement).




回答2:


You should be able to configure the the ASP.NET membership database connection string at runtime. This thread has a few options including a custom membership provider or changing the value early on in the request lifecycle via Global.asax.cs.



来源:https://stackoverflow.com/questions/483414/converting-single-db-asp-net-site-into-multitenant-membership-and-roles-dilemm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!