Skip to content

JonPSmith/AuthP.CustomDatabaseExamples

Repository files navigation

AuthPermissions.CustomDatabaseExamples

This repo contains examples of using a custom database provider when using the AuthPermissions.AspNetCore (shortened to AuthP). Go to the the AuthP's documentation wiki and look for "custom database" for more information.

Before the 5.0.0 release of the AuthP library you only select the built-in SqlServer or PostgreSQL database providers. With the release of AuthP 5.0.0 you can use the main database providers that EF Core supports

Supported database providers in V5.0.0 Comment
Microsoft.EntityFrameworkCore.SqlServer Built-in
Npgsql.EntityFrameworkCore.PostgreSQL Built-in
Microsoft.EntityFrameworkCore.Sqlite See examples in this repo
Microsoft.EntityFrameworkCore.Cosmos
Pomelo.EntityFrameworkCore.MySql Pomelo Foundation Project
MySql.EntityFrameworkCore MySQL project
Oracle.EntityFrameworkCore Oracle

For normal (non-sharding) applications you can use one type of database, but with sharding / hybrid applications you can use multiple database providers, e.g. SqlServer for the admin part and CosmosDB for the tenant databases.

Examples in this repo

This repo contains two examples of using AuthP's "custom databases" feature. They are

  • CustomDatabase1 example, which for normal multi-tenant application
  • CustomDatabase2 example, which for sharding / hybrid multi-tenant application

These examples are details below

CustomDatabase1: normal multi-tenant application

NOTE: Go to the article "Using custom databases with the AuthP library – Part1: normal apps" for much more detail account of how use a custom database in an normal multi-tenant AuthP application.

The first example is for an normal (i.e. not sharding / hybrid) multi-tenant application. This example has three projects, all starting with CustomDatabase1.. This uses the Sqlite database provider, mainly because the ASP.NET Core Individual User Accounts Authentication supports Sqlite too. The are three projects are listed below:

Projects What they contain
CustomDatabase1.InvoiceCode The per-tenant code - an demo invoice app
CustomDatabase1.SqliteCustomParts The code to use Sqlite to AuthP
CustomDatabase1.WebApp The example WebApp to see how it works

NOTE: Sqlite is different to other database providers as its connection string needs a FilePath to be added to the connection string. I solve this at the start of the ASP.NET Core's Program.

CustomDatabase2: sharding multi-tenant application

The second example is for sharding / hybrid multi-tenant application, which is more complex than CustomDatabase1. This example uses a sharding approach with each tenant having their own Sqlite database.

This example has three projects, all starting with CustomDatabase2.. This uses the Sqlite database provider, mainly because the ASP.NET Core Individual User Accounts Authentication supports Sqlite too. The are three projects are listed below:

Projects What they contain
CustomDatabase2.InvoiceCode.Sharding The per-tenant code - an demo invoice app
CustomDatabase2.SqliteCustomParts.Sharding The code to use Sqlite to AuthP
CustomDatabase2.WebApp.Sharding The example WebApp to see how it works

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages