Bootproject.Multitenancy.Core
2.1.0
See the version list below for details.
dotnet add package Bootproject.Multitenancy.Core --version 2.1.0
NuGet\Install-Package Bootproject.Multitenancy.Core -Version 2.1.0
<PackageReference Include="Bootproject.Multitenancy.Core" Version="2.1.0" />
paket add Bootproject.Multitenancy.Core --version 2.1.0
#r "nuget: Bootproject.Multitenancy.Core, 2.1.0"
// Install Bootproject.Multitenancy.Core as a Cake Addin #addin nuget:?package=Bootproject.Multitenancy.Core&version=2.1.0 // Install Bootproject.Multitenancy.Core as a Cake Tool #tool nuget:?package=Bootproject.Multitenancy.Core&version=2.1.0
Bootproject.Multitenancy (Core 2.2)
This project is an extension of nHibernate's ISessionFactory and makes it incredible easy to use multiple sessions within the same application. It's used to define different domains and their databases. Uses MySql as database.
Since the previous versions in .Net 4.6 this is more lightweighted, without
lack of functionallity.
Built in model creation. When adding a new model its automatically gets replicated in database.
Setup
Reference Multitenancy to your project, and in Startup.cs add:
//Add (in ConfigureServices)
services.AddMultitenancy();
//And (in Configure before app.UseMvc())
app.UseMultitenancy();
Configuration
Add "DomainConfiguration" section to appsettings.json like the example below:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"DomainConfiguration": {
"Domains": [
{
"Name": "bootproject",
"Dns": "localhost,bootproject.net",
"ConnectionString": "server=localhost;port=3306;database=test1;uid=root;password=1234"
},
{
"Name": "example",
"Dns": "example.com",
"ConnectionString": "server=localhost;port=3306;database=test2;uid=root;password=1234"
}
]
},
"AllowedHosts": "*"
}
Note: - Default domain will always be localhost.
How to use
Adding a model:
[Table("Pages")]
public class Page : IEntity
{
public virtual int Id{ get; set;}
public virtual string Title{ get; set}
//.....
}
//In controller
private readonly ISession Session;
public HomeController()
{
Session = Host.Open();
}
public IActionResult Index()
{
var model = Session.All<Page>();
if (!model.Any()) {
var page = new Page { Id=1, Title="Start" };
Session.Save<Page>(page);
Session.Flush();
}
return View(model);
}
Caching
In Bootproject.Multitenancy project theres built in cache of Entities. When for eg. calling All<T>.First(t=> t.Id==1) wich makes a call for all T could be a performance issue, but since its already in the cache, this is not a problem.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.2 is compatible. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.2
- FluentNHibernate (>= 2.1.2)
- Microsoft.AspNetCore.App (>= 2.2.0)
- MySql.Data (>= 8.0.17)
- System.Runtime.Caching (>= 4.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
First release of Bootproject.Multitenancy for ,net Core 2.2