Wiki

Clone wiki

Bootproject.Core / Home

Bootproject Multitenancy

For: AspNet Core 2.0

This project is an extension of nHibernate's ISessionFactory and makes it incredible easy to use multiple sessions within the same application. In BootCms it's used to define different domains and their databases. Boot.Multitenancy has Fluentnhibernate built in, so no need for extra configuration except setting up databases configuration in bootproject.json. It also has features like modelling classes with nHibernate. And as always!!! Add references to your database of choice!!

Application use: Add these 2 lines: * services.AddMultitenancy(); * app.UseMultitenancy();

Add service

#!c#

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddMultitenancy();//add multitenancy
        }

Add configuration

#!c#

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseBrowserLink();
            app.UseDeveloperExceptionPage();
            app.UseStaticFiles(); //For Css etc.

            app.UseMultitenancy(); //Init the multitenancy

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }

Example configuration (bootproject.json) in root of application

#!json

{
  "Sites": [
    {
      "Name": "domainone",
      "Connectionstring": "server=localhost;port=3306;database=domainone;SslMode=none;uid=root;password=1234",
      "Domains": [ "domainone.com" ],
      "DbType": "MySql"
    },
    {
      "Name": "domaintwo",
      "Connectionstring": "server=localhost;port=3306;database=domaintwo;SslMode=none;uid=root;password=1234",
      "domains": [ "localhost", "domaintwo.com" ],
      "DbType": "MySql"
    }
  ],
}

Modelling How to use the built in nHibernate?

Updated