Skip to content

Version 1 Limitations

Jon P Smith edited this page Aug 25, 2021 · 2 revisions

Version 1 of the AuthP library has some limitations around an ASP.NET Core application that has run multiple instances, known as scale out. The problem with multiple instances starting up at the same time you cannot setup a database or similar on startup, because each instance will try to apply the database multiple times, which won't work.

NOTE: Version 2 of AuthP library will contain a feature that can get around these issues via a "run each in turn" library.

The most important issue is migrating the AuthP's database on startup, but I have listed all possible methods / settings that won't work (most of these are only used in the example applications in the AuthP repo).

Migrating the AuthP's database on startup

The problem is if you run multiple EF Core's migrations running at the same time, then they will fail. Therefore you cannot use AuthP's SetupAspNetCoreAndDatabase() extension, which applies a migration during the startup of the ASP.NET Core application.

The solution is to:

  1. Manually migrate the AuthP's database, either by:
    • Use EF Core's dotnet ef database update command to migrate the database
    • Obtaining the SQL migration script via EF Core's dotnet ef migrations script command and applying it to the database
    • Creating a stand-alone application that accesses the AuthP library (you can obtain the AuthPermissionsDbContext from the services and then call the context.Database.Migrate method.
    • Or many other ways...
  2. Replace the SetupAspNetCoreAndDatabase() with the SetupAspNetCorePart() extension method in the registering of the AuthP library in the Startup class. This will ensure that AuthP does not try to migrate the AuthP database.

You can't use the AddSuperUserToIndividualAccounts() method

The AuthP's AddSuperUserToIndividualAccounts() method is a quick way to add an admin user, but the method might throw an exception on startup due to multiple calls clashing.

You can't use bulk loading on startup

The examples applications in the AuthP's repo use Bulk Loading to set up the AuthP's Roles, Tenants and Users.

This isn't a big issue in a real application, but if you do need lots of Roles, Tenants or Users added to your application you could create a method / page that can be called manually by an admin user once the application is running.

Articles / Videos

Concepts

Setup

Usage

Admin

SupportCode

Clone this wiki locally