Databases
The plugin has its own SuperAdminDbContext and connection string. Its tables can live in your app database or in a separate one, even on another database server.
Tables
With the default prefix sa_:
sa_users, sa_roles, sa_permissions, sa_permission_routes, sa_menus, sa_user_roles, sa_role_permissions, sa_user_permissions, sa_role_menus, sa_operation_logs, sa_settings.
All DateTime values are stored and read as UTC (DateTimeKind.Utc), so ToLocalTime() gives the right local time.
Supported databases
Install the EF Core 10 provider for your database and pass it to AddSuperAdmin:
| Database | Provider package | AddSuperAdmin(..., db => ...) | Tested |
|---|---|---|---|
| SQL Server, Azure SQL, LocalDB | Microsoft.EntityFrameworkCore.SqlServer | db.UseSqlServer(cs) | Yes (LocalDB) |
| PostgreSQL | Npgsql.EntityFrameworkCore.PostgreSQL | db.UseNpgsql(cs) | Yes (17) |
| MySQL | MySql.EntityFrameworkCore (Oracle's provider) | db.UseMySQL(cs) | Yes (9.1) |
| Oracle 23ai | Oracle.EntityFrameworkCore | db.UseOracle(cs) | Script and model checks only |
| Oracle 19c / 21c | Oracle.EntityFrameworkCore | db.UseOracle(cs, o => o.UseOracleSQLCompatibility(OracleSQLCompatibility.DatabaseVersion19)) | Script and model checks only |
| SQLite | Microsoft.EntityFrameworkCore.Sqlite | db.UseSqlite(cs) | Yes |
| MongoDB | - | Not supported | - |
"Yes" means the provider test suite (tests/.../ProviderTests.cs: create, seed, users, roles, permissions, menus, import with explicit ids, UTC dates, log purge, install/re-run/upgrade scripts) passes against a real server. Run it against your own server with SA_TEST_SQLSERVER, SA_TEST_POSTGRES, SA_TEST_MYSQL or SA_TEST_ORACLE set to a connection string.
Provider notes
- MySQL / MariaDB:
Pomelo.EntityFrameworkCore.MySqlhas no EF Core 10 release yet (latest 9.0.0), so useMySql.EntityFrameworkCore. To run the SQL scripts through ADO.NET, addAllow User Variables=Trueto the connection string. MariaDB is not tested. - Oracle:
''isNULLin Oracle, so the "any method" columnsa_permission_routes.HttpMethodsis nullable there. JSON attributes, logged input and settings areNCLOB. The shippedsql/oraclescripts useBOOLEAN(23ai). For 19c/21c, set the compatibility option above and generate the script withsuperadmin sql-script. - MongoDB: the plugin needs a relational database (joins, integer identities, transactions). If your app data is in MongoDB, keep the plugin tables in a small relational database, for example SQLite or PostgreSQL. Only the admin users, roles and permissions live there.
Modes
InitializeSuperAdminAsync() handles the schema according to Database:Mode. Then it checks every plugin table and column, and stops the app with a clear error if one is missing, instead of failing on the first request.
| Mode | What it does |
|---|---|
Auto (default) | Apply your EF Core migrations if the app has them, otherwise like Create |
Create | Create the plugin tables if none exist, and add nullable columns introduced by newer package versions. Works in a database that already has your tables |
Migrate | Apply your EF Core migrations only |
None | Touch nothing, only check. For teams that create schemas with reviewed SQL scripts |
To manage the schema yourself, see Migrations and SQL scripts.