使用基于插件的ASP架构开发多租户应用程序。NET MVC

时间:2022-10-21 04:14:02

I am developing a multi-tenant application using ASP.NET MVC, and after doing a good research on multi-tenancy and SaaS I have found there are many resources available to implement data layer (database: separation by Schema, by database or shared) but very limited resources are available to implement Business and UI layer though.

我正在使用ASP开发一个多租户应用程序。NET MVC,在对多租户和SaaS做了很好的研究之后,我发现有很多资源可以实现数据层(数据库:根据模式进行分离、通过数据库或共享),但是实现业务层和UI层的资源非常有限。

I have picked up separate database approach.

我采用了单独的数据库方法。

Now in order to make it truly multi-tenant I have chosen plugin based architecture (like umbraco and Nopcommerce) where plugin is an MVC application with tenant based model, view and controller.

为了实现真正的多租户,我选择了基于插件的体系结构(比如umbraco和Nopcommerce),其中的插件是一个MVC应用程序,具有基于租户的模型、视图和控制器。

Here is how I am going to develop it:

下面是我将如何发展它:

  • Controller factory will be initialized based on tenant (subdomain)

    控制器工厂将根据租户(子域)进行初始化

  • Business layer will be injected (using DI) based on tenant.

    业务层将基于租户注入(使用DI)。

  • and UI (View) will be rendered based on plugin.

    UI(视图)将基于插件呈现。

But in this way everything is being redundant, not able to share common behaviour.

但以这种方式,一切都是多余的,无法分享共同的行为。

Can anyone help to design it the way I can share common behaviour or is there any better approach doing so?

有没有人能帮我设计出一种我可以分享共同行为的方式呢?

1 个解决方案

#1


1  

I have successfully implemented similar architecture using DI/IoC to inject the correct configuration based on the current logged-in user's tenant. Autofac provides a multi-tenant capability out of the box, I would recommend you check it out.

我已经成功地使用DI/IoC实现了类似的体系结构,以便基于当前登录用户的租户注入正确的配置。Autofac提供了一种开箱即用的多租户功能,我建议您查看它。

http://docs.autofac.org/en/latest/advanced/multitenant.html

http://docs.autofac.org/en/latest/advanced/multitenant.html

Sorry for the short answer, writing on mobile is challenging. I will try to edit and expand the answer later when I get to my PC

很抱歉这么简短的回答,在手机上写作很有挑战性。稍后当我到达我的电脑时,我会尝试编辑和展开答案

#1


1  

I have successfully implemented similar architecture using DI/IoC to inject the correct configuration based on the current logged-in user's tenant. Autofac provides a multi-tenant capability out of the box, I would recommend you check it out.

我已经成功地使用DI/IoC实现了类似的体系结构,以便基于当前登录用户的租户注入正确的配置。Autofac提供了一种开箱即用的多租户功能,我建议您查看它。

http://docs.autofac.org/en/latest/advanced/multitenant.html

http://docs.autofac.org/en/latest/advanced/multitenant.html

Sorry for the short answer, writing on mobile is challenging. I will try to edit and expand the answer later when I get to my PC

很抱歉这么简短的回答,在手机上写作很有挑战性。稍后当我到达我的电脑时,我会尝试编辑和展开答案