Version 5.0.0 of the AuthPermissions.AspNetCore library (shortened to AuthP from now on) contains various new features (LINK TO roadmap), but this document covers BREAKING CHANGES in version 5.0.0, which are in sharding multi-tenant applications. I purposely cause compile errors so that the breaking changes are obvious to you.
- The
IAccessDatabaseInformation
interface has changed and will cause an compile error. - Some sharding services have different properties, causing compile errors.
- You need to use the new
SetupMultiTenantSharding
extension method to set up a hybrid / sharding. - If you are using the Postgres database, then you need to update the sharding information in your apps.
- The
IGetDatabaseForNewTenant
has changed.
The subsections below the items listed in the table of content.
The IAccessDatabaseInformation
interface is now called IAccessDatabaseInformationVer5
. Before version 5.0.0 you needed register IAccessDatabaseInformation
in your Program
class with the following code.
builder.Services.AddTransient<IAccessDatabaseInformation, AccessDatabaseInformation>();
Solution: remove the IAccessDatabaseInformation
registration code and use the new SetupMultiTenantSharding
extension method to setup the sharding.
The IAccessDatabaseInformationVer5
have new and renamed methods and properties.
Solution: Look at the Example6 ShardingController for the changed parts.
Setting up a AuthP's sharding / hybrid multi-tenant application is now done by the SetupMultiTenantSharding
extension method.
Solution: add the new SetupMultiTenantSharding
extension method to your AuthP's registration in your Program
class.
NOTE: SetupMultiTenantSharding
set up the sharding, but you still define the options.TenantType
to TenantTypes.SingleLevel
or TenantTypes.HierarchicalTenant
.
Because of the new custom database feature the DatabaseType
in your shardingsetting.json file MUST MATCH the context.Database.ProviderName
short name, e.g. the Microsoft.EntityFrameworkCore.SqlServer
short name is SqlServer
The problem with Postgres database is Npgsql.EntityFrameworkCore.PostgreSQL
so the short name is PostgreSQL
, not Postgres
Solution: make sure your shardingsetting.json entries that use Postgres has the DatabaseType
set to "PostgreSQL".
NOTE: If you don't change this you will have an exception with the following message.
The Postgres database provider isn't supported.
Its unlike you have used this service, but it has been changed to allow it to create a database. The version 4 implementation could only select an existing database, but the version 5 allows to create a database.
Solution: change your implementation of the IGetDatabaseForNewTenant
to match the new format - see the DemoGetDatabaseForNewTenant for an example, and another in the AuthPermissions.CustomDatabaseExamples sharding repo.
END