ASP.NET MVC 5,实体框架,Ninject和多租户安装租户、实体、框架、NET

2023-09-03 04:00:55 作者:今日为小编为小主们带来一组六个字的抖音名字,又潮又个性,值得

我试图找到一种多租户设置为我工作的一个应用程序的最佳方法。当前应用程序是专为篮球,但想用同样的codeBase的足球。

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.

该应用程序会改变颜色,图案,和其他一些作品的code和意见可能会被显示或隐藏。这都将基于应用的租户运动使用的URL。

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.

我使用ASP.NET MVC 5,Ninject和实体框架6.我要在我的数据库中存储的URL等相关信息,它创建一个租户表。

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.

在应用程序启动时什么是检索租户,并存储该用户的最佳方法是什么?请记住,用户可以浏览到其他体育网站,请保持相同的登录,但将只加载与该租户的信息。将一个cookie是最好的选择吗?我需要一种方法,通过服务层还访问房客。

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.

我可以使用 https://github.com/jbogard/EntityFramework.Filters 为在某些表实体框架过滤不仅关系到体育运动。不过,我怎么能访问TenantID做到这一点?将某种类型的静态工厂工作?

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?

推荐答案

您可以看看的 AspNet.Identity ,这样可以让你来验证用户/租户,存储的个人资料信息为每个用户/租户和使用角色或索赔授权的网站的不同部分

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.