I am trying to find the best approach for a multi tenancy setup for an application I am working on. The current application is specifically for basketball but would like to use the same codebase for football.
The application would change colors, logo, and some other pieces of code and views might be shown or hidden. This will all be based on the URL of the application for sport tenant to use.
I am using ASP.NET MVC 5, Ninject and Entity Framework 6. I am going to create a Tenant table in my database that stores the URL and other related information to it.
When the application starts up what is the best way to retrieve the tenant and store it for that user? Keep in mind the user may navigate to the other sport site, keep same login, but would load only the information related to that tenant. Would a cookie be the best bet here? I will need a way to access the tenant through the services layer also.
I may use https://github.com/jbogard/EntityFramework.Filters for the Entity Framework filtering on certain tables only related to that sport. However how can I access the TenantID to do this? Would a static factory of some sort work?
You can have a look at AspNet.Identity, which would allow you to authenticate users/tenants, store profile information for each user/tenant and to use roles or claims for authorization for different parts of the website.
来源:https://stackoverflow.com/questions/26103610/asp-net-mvc-5-entity-framework-ninject-and-multi-tenancy-setup