Skip to content
Promote Your Product

Upgrade Instructions

v9.1.3

This upgrade mainly implements log database separation and upgrade slider verification code plugin to improve the system's concurrent processing capability, security and code maintainability.

1. Database Configuration Adjustment

  • Change Type: Function Enhancement
  • Description: Separate the log database from the original admindb and add an independent logdb database to improve interface concurrent processing capability.
  • Related Files: dbconfig.json
  • Configuration Changes:
    • Add logdb database configuration under the dbs node
    • Adjust admindb's excludeEntityDbs to exclude log-related entities

For the sys project created with the Zhontai.Template.App project template, ConfigCenter/dbconfig.json configuration example:

dbconfig.json
json
{
  "DbConfig": {
    //Database registration key
    "key": "sysdb",
    //Assembly name, automatically get entity tables, if empty, customize configuration through ConfigureFreeSql
    "assemblyNames": [ "MyCompanyName.MySys.Api" ],
    //Specify entity database list, sync all database table entities if not filled
    "includeEntityDbs": [],
    //Exclude entity database list, specify not to sync database table entities
    "excludeEntityDbs": [],

    //Monitor all operations
    "monitorCommand": false,
    //Monitor Curd operations
    "curd": true,
    //Monitor sync structure scripts
    "syncStructureSql": false,
    //Monitor sync data Curd operations
    "syncDataCurd": false,

    //Create database
    "createDb": true,
    //SqlServer,PostgreSQL,Oracle,OdbcOracle,OdbcSqlServer,OdbcMySql,OdbcPostgreSQL,Odbc,OdbcDameng,MsAccess
    //Create database connection string
    //default_authentication_plugin = caching_sha2_password 
    //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
    //default_authentication_plugin = mysql_native_password
    //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
    //SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=master;Encrypt=True;TrustServerCertificate=True;Pooling=true;Min Pool Size=1"
    //PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=postgres;Pooling=true;Minimum Pool Size=1"
    //Oracle "user id=SYS;password=pwd; data source=//127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1"
    "createDbConnectionString": "",
    //Create database script, complex create database scripts can be placed in createdbsql.txt
    //MySql "CREATE DATABASE `sysdb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'"
    //SqlServer "CREATE DATABASE [sysdb]"
    //PostgreSQL "CREATE DATABASE \"sysdb\" WITH ENCODING = 'UTF8'"
    "createDbSql": "",

    //Sync structure
    "syncStructure": true,
    //Sync structure batch entity count
    "syncStructureEntityBatchSize": 1,
    //Sync data batch processing size, default 500 items per processing, too large may cause memory overflow
    "syncDataBatchSize": 500,
    //Sync data
    "syncData": true,
    //Note: Use with caution in production environment, make sure to modify table data is the latest data before opening.
    //If you don't want to update certain table data, you can first configure sync data exclude tables syncDataExcludeTables, then execute data update operations
    //Sync update data
    "syncUpdateData": false,
    ////Sync data address
    "SyncDataPath": "InitData/App",
    //Sync data include tables, specify table sync, sync all tables if not filled
    "syncDataIncludeTables": [],
    //Sync data exclude tables, specify tables not to sync
    "syncDataExcludeTables": [],
    //Sync data operation user
    "syncDataUser": {
      "id": 161223411986501,
      "userName": "admin",
      "name": "Admin",
      "tenantId": 161223412138053
    },

    //Project initialization does not enable data generation, before publishing to production environment, if development environment has configuration data that needs to update data packages, you can enable data generation, remember to turn it off after use
    //Turn off syncStructure syncData createDb before enabling data generation
    //Generate data
    "generateData": false,

    //Database configuration https://github.com/dotnetcore/FreeSql/wiki/Getting-Started
    //Connection string syntax https://www.connectionstrings.com
    //Database type MySql = 0, SqlServer = 1, PostgreSQL = 2, Oracle = 3, Sqlite = 4, OdbcOracle = 5, OdbcSqlServer = 6, OdbcMySql = 7, OdbcPostgreSQL = 8, Odbc = 9, OdbcDameng = 10, MsAccess = 11, Dameng = 12, OdbcKingbaseES = 13, ShenTong = 14, KingbaseES = 15, Firebird = 16
    "type": "Sqlite",

    //Connection string
    //default_authentication_plugin = caching_sha2_password 
    //MySql "Server=localhost; Port=3306; Database=sysdb; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
    //default_authentication_plugin = mysql_native_password
    //MySql "Server=localhost; Port=3306; Database=sysdb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
    //SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=sysdb;Encrypt=True;TrustServerCertificate=True;Pooling=true;Min Pool Size=1"
    //PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=sysdb;Pooling=true;Minimum Pool Size=1"
    //Sqlite "Data Source=|DataDirectory|\\sysdb.db; Pooling=true;Min Pool Size=1"
    //"Oracle" "user id=SYS;password=pwd; data source=//127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1",
    "connectionString": "Data Source=|DataDirectory|\\sysdb.db; Pooling=true;Min Pool Size=1",

    //Specify assembly
    //FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector
    "providerType": "",

    //Read-write separation slave list
    "slaveList": [
      //{
      //  //Weight
      //  "Weight": 1,
      //  //Connection string
      //  "ConnectionString": "Data Source=|DataDirectory|\\sysdb.db; Pooling=true;Min Pool Size=1"
      //}
    ],

    //Idle time (minutes), set idleTime=0 to not automatically recycle, set 1 day not used to automatically recycle
    "idleTime": 1440,

    //Force update EntityUpdate data when adding
    "forceUpdate": false,

    //Multiple databases
    //Core/Consts define DbKeys enum
    //Use repository access public ModuleRepository(UnitOfWorkManagerCloud muowm) : base(DbKeys.sysdb, muowm)
    //Use FreeSqlCloud access freeSqlCloud.Use(DbKeys.sysdb);
    "dbs": [
      {
        //Permission database
        "key": "admindb",
        //Assembly name, automatically get entity tables
        "assemblyNames": [ "ZhonTai.Admin" ],
        //Specify entity database list, sync all database table entities if not filled
        "includeEntityDbs": [],
        //Exclude entity database list, specify not to sync database table entities
        "excludeEntityDbs": [ "Log" ],

        //Monitor all operations
        "monitorCommand": false,
        //Monitor Curd operations
        "curd": true,
        //Monitor sync structure scripts
        "syncStructureSql": false,
        //Monitor sync data Curd operations
        "syncDataCurd": false,

        //Create database
        "createDb": true,
        //SqlServer,PostgreSQL,Oracle,OdbcOracle,OdbcSqlServer,OdbcMySql,OdbcPostgreSQL,Odbc,OdbcDameng,MsAccess
        //Create database connection string
        //default_authentication_plugin = caching_sha2_password 
        //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
        //default_authentication_plugin = mysql_native_password
        //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
        //SqlServer "Data Source=.;User Id=sa;Password=pwd;Initial Catalog=master;TrustServerCertificate=true;Pooling=true;Min Pool Size=1"
        //PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=postgres;Pooling=true;Minimum Pool Size=1"
        //Oracle "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1"
        "createDbConnectionString": "",
        //Create database script, complex create database scripts can be placed in createdbsql.txt
        //MySql "CREATE DATABASE `admindb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'"
        //SqlServer "CREATE DATABASE [admindb]"
        //PostgreSQL "CREATE DATABASE \"admindb\" WITH ENCODING = 'UTF8'"
        "createDbSql": "",

        //Sync structure
        "syncStructure": true,
        //Sync structure batch entity count
        "syncStructureEntityBatchSize": 1,
        //Sync data batch processing size, default 500 items per processing, too large may cause memory overflow
        "syncDataBatchSize": 500,
        //Sync data
        "syncData": true,
        //Sync update data, note: use with caution in production environment, make sure to modify table data is the latest data before opening. If you don't want to update certain table data, you can first configure sync data exclude tables syncDataExcludeTables, then execute data update operations
        "syncUpdateData": false,
        //Sync data address
        "SyncDataPath": "InitData/App",
        //Sync all tables ["base_dict_type", "base_dict", "base_user",  "base_user_staff", "base_org", "base_role", "base_api", "base_view", "base_permission", "base_permission_api", "base_user_role", "base_user_org", "base_role_permission", "base_tenant", "base_tenant_permission"]
        //Sync specified tables ["base_api", "base_view", "base_permission", "base_permission_api"]
        //Sync data include tables, specify table sync, sync all tables if not filled
        "syncDataIncludeTables": [],
        //Sync exclude tables ["base_user"]
        //Sync data exclude tables, specify tables not to sync
        "syncDataExcludeTables": [],
        //Sync data operation user
        "syncDataUser": {
          "id": 161223411986501,
          "userName": "admin",
          "name": "Admin",
          "tenantId": 161223412138053
        },

        //Project initialization does not enable data generation, before publishing to production environment, if development environment has configuration data that needs to update data packages, you can enable data generation, remember to turn it off after use
        //Turn off syncStructure syncData createDb before enabling data generation
        //Generate data
        "generateData": false,

        //Database configuration https:github.com/dotnetcore/FreeSql/wiki/Getting-Started
        //Connection string syntax https:www.connectionstrings.com
        //Database type MySql = 0, SqlServer = 1, PostgreSQL = 2, Oracle = 3, Sqlite = 4, OdbcOracle = 5, OdbcSqlServer = 6, OdbcMySql = 7, OdbcPostgreSQL = 8, Odbc = 9, OdbcDameng = 10, MsAccess = 11, Dameng = 12, OdbcKingbaseES = 13, ShenTong = 14, KingbaseES = 15, Firebird = 16
        "type": "Sqlite",

        //Connection string
        //default_authentication_plugin = caching_sha2_password 
        //MySql "Server=localhost; Port=3306; Database=admindb; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
        //default_authentication_plugin = mysql_native_password
        //MySql "Server=localhost; Port=3306; Database=admindb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
        //SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=admindb;Pooling=true;Min Pool Size=1"
        //PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=admindb;Pooling=true;Minimum Pool Size=1"
        //Sqlite "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1"
        //"Oracle" "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1",
        "connectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1",

        //Specify assembly
        //FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector
        "providerType": "",

        //Read-write separation slave list
        "slaveList": [
          //{
          //  Weight
          //  "Weight": 1,
          //  Connection string
          //  "ConnectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1"
          //}
        ]
      },
      {
        //Log database
        "key": "logdb",
        //Assembly name, automatically get entity tables
        "assemblyNames": [ "ZhonTai.Admin" ],
        //Specify entity database list, sync all database table entities if not filled
        "includeEntityDbs": [ "Log" ],
        //Exclude entity database list, specify not to sync database table entities
        "excludeEntityDbs": [],

        //Monitor all operations
        "monitorCommand": false,
        //Monitor Curd operations
        "curd": true,
        //Monitor sync structure scripts
        "syncStructureSql": false,
        //Monitor sync data Curd operations
        "syncDataCurd": false,

        //Create database
        "createDb": true,
        //SqlServer,PostgreSQL,Oracle,OdbcOracle,OdbcSqlServer,OdbcMySql,OdbcPostgreSQL,Odbc,OdbcDameng,MsAccess
        //Create database connection string
        //default_authentication_plugin = caching_sha2_password 
        //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
        //default_authentication_plugin = mysql_native_password
        //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
        //SqlServer "Data Source=.;User Id=sa;Password=pwd;Initial Catalog=master;TrustServerCertificate=true;Pooling=true;Min Pool Size=1"
        //PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=postgres;Pooling=true;Minimum Pool Size=1"
        //Oracle "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1"
        "createDbConnectionString": "",
        //Create database script, complex create database scripts can be placed in createdbsql.txt
        //MySql "CREATE DATABASE `logdb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'"
        //SqlServer "CREATE DATABASE [logdb]"
        //PostgreSQL "CREATE DATABASE \"logdb\" WITH ENCODING = 'UTF8'"
        "createDbSql": "",

        //Sync structure
        "syncStructure": true,
        //Sync structure batch entity count
        "syncStructureEntityBatchSize": 1,
        //Sync data batch processing size, default 500 items per processing, too large may cause memory overflow
        "syncDataBatchSize": 500,
        //Sync data
        "syncData": false,
        //Sync update data, note: use with caution in production environment, make sure to modify table data is the latest data before opening. If you don't want to update certain table data, you can first configure sync data exclude tables syncDataExcludeTables, then execute data update operations
        "syncUpdateData": false,

        //Project initialization does not enable data generation, before publishing to production environment, if development environment has configuration data that needs to update data packages, you can enable data generation, remember to turn it off after use
        //Turn off syncStructure syncData createDb before enabling data generation
        //Generate data
        "generateData": false,

        //Database configuration https:github.com/dotnetcore/FreeSql/wiki/Getting-Started
        //Connection string syntax https:www.connectionstrings.com
        //Database type MySql = 0, SqlServer = 1, PostgreSQL = 2, Oracle = 3, Sqlite = 4, OdbcOracle = 5, OdbcSqlServer = 6, OdbcMySql = 7, OdbcPostgreSQL = 8, Odbc = 9, OdbcDameng = 10, MsAccess = 11, Dameng = 12, OdbcKingbaseES = 13, ShenTong = 14, KingbaseES = 15, Firebird = 16
        "type": "Sqlite",

        //Connection string
        //MySql "Server=localhost; Port=3306; Database=logdb; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
        //default_authentication_plugin = mysql_native_password
        //MySql "Server=localhost; Port=3306; Database=logdb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
        //SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=logdb;Pooling=true;Min Pool Size=1"
        //PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=logdb;Pooling=true;Minimum Pool Size=1"
        //Sqlite "Data Source=|DataDirectory|\\logdb.db; Pooling=true;Min Pool Size=1"
        //"Oracle" "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1",
        "connectionString": "Data Source=|DataDirectory|\\logdb.db; Pooling=true;Min Pool Size=1",

        //Specify assembly
        //FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector
        "providerType": "",

        //Read-write separation slave list
        "slaveList": [
          //{
          //  Weight
          //  "Weight": 1,
          //  Connection string
          //  "ConnectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1"
          //}
        ]
      }
    ]
  }
}

Note

logdb can be configured as an independent database or configured into the application database. It is recommended to configure it as an independent database to avoid excessive application database data volume.

2. Log Database Initialization

  • Change Type: New Feature
  • Description: Automatically initialize the log database when the program starts to ensure independent storage of log data.
  • Related Files: Program.cs
  • Code Changes:
    csharp
    ConfigurePreFreeSql = (freeSql, dbConfig) =>
    {
        freeSql.UseLogDb(dbConfig); // New: Use independent log database
    }

3. Slider Verification Code Function Integration

  • Change Type: New Feature
  • Description: Integrate slider verification code function (included in ZhonTai.Admin.Contracts library), no need to reference additional plugins, enhance system security.
  • Related Files: Program.cs
  • Code Changes:
    csharp
    ConfigurePostServices = context =>
    {
        // Add slider verification service (built into ZhonTai.Admin.Contracts)
        context.Services.AddSlideCaptcha();
    }

4. Multi-Repository Generic Injection Support

  • Change Type: Function Enhancement
  • Description: Support automatic injection of basic repositories for application database, permission database, and log database. Entity repositories can be quickly built based on basic repositories.
  • Related Files: Program.cs
  • Code Changes:
    csharp
    ConfigureAutofacContainer = (builder, context) =>
    {
        builder.RegisterGeneric(typeof(AppRepositoryBase<>)).InstancePerLifetimeScope();
        builder.RegisterGeneric(typeof(AdminRepositoryBase<>)).InstancePerLifetimeScope();
        builder.RegisterGeneric(typeof(LogRepositoryBase<>)).InstancePerLifetimeScope();
    }