TL;DR Version:
To modify the table name prefix and schema of built-in tables in the Abp framework, follow these steps:
- Generate a template project using the CLI command
abp new MyApp
. - Open the
MyApp.EntityFrameworkCore
project and delete theMigrations
folder. - In the
MyApp.EntityFrameworkCore
project, open theEntityFrameworkCore/MyAppDbContext.cs
file. - Find the
OnModelCreating
method and explore thebuilder.ConfigureXXX()
methods to see the source code implementation. - Modify the default configuration by setting the values of
AbpCommonDbProperties.DbTablePrefix
andAbpCommonDbProperties.DbSchema
in the startup projects'Program.cs
files andXXXDbContextFactory.cs
file. - Delete the
Migrations
folder in theXXX.EntityFrameworkCore
project and run theXXX.DbMigrator
project to generate migration files. - Open the
Migrations/MyAppDbContextModelSnapshot.cs
file and verify that the generated migration code reflects the updated configuration. - For special tables, such as those with the
OpenIddict
prefix, set the values ofAbpOpenIddictDbProperties.DbTablePrefix
andAbpOpenIddictDbProperties.DbSchema
in the startup projects'Program.cs
files andXXXDbContextFactory.cs
file. - Delete the
Migrations
folder, clear the database, and run theXXX.DbMigrator
project to apply the migration. - For individual configurations, find the corresponding configuration in the
OnModelCreating
method of theMyAppDbContext.cs
file and set the values in the startup projects'Program.cs
files andXXXDbContextFactory.cs
file. - Modify the table name prefix and schema of user tables in the
MyApp.Domain
project'sMyAppConsts.cs
file.
Detailed Version:
To modify the table name prefix and schema of built-in tables in the Abp framework, follow these steps:
-
Generate a template project using the CLI command
abp new MyApp
. -
Open the
MyApp.EntityFrameworkCore
project and delete theMigrations
folder. This folder contains the default migration files. -
In the
MyApp.EntityFrameworkCore
project, open theEntityFrameworkCore/MyAppDbContext.cs
file. This file contains the configuration for the built-in tables. -
Find the
OnModelCreating
method in theMyAppDbContext.cs
file. This method contains the configuration for the built-in tables. -
Explore the
builder.ConfigureXXX()
methods in theOnModelCreating
method to see the source code implementation. These methods configure the tables and their prefixes and schemas. -
Modify the default configuration by setting the values of
AbpCommonDbProperties.DbTablePrefix
andAbpCommonDbProperties.DbSchema
in the startup projects'Program.cs
files andXXXDbContextFactory.cs
file. These files are located in the startup projects (excludingXXX.DbMigrator
). -
Delete the
Migrations
folder in theXXX.EntityFrameworkCore
project. This folder contains the default migration files. -
Run the
XXX.DbMigrator
project to generate migration files based on the updated configuration. -
Open the
Migrations/MyAppDbContextModelSnapshot.cs
file and verify that the generated migration code reflects the updated configuration. The table name prefix and schema should be modified accordingly. -
For special tables, such as those with the
OpenIddict
prefix, set the values ofAbpOpenIddictDbProperties.DbTablePrefix
andAbpOpenIddictDbProperties.DbSchema
in the startup projects'Program.cs
files andXXXDbContextFactory.cs
file. These files are located in the startup projects (excludingXXX.DbMigrator
). -
Delete the
Migrations
folder, clear the database, and run theXXX.DbMigrator
project to apply the migration. The special tables should now have the modified table name prefix and schema. -
For individual configurations, find the corresponding configuration in the
OnModelCreating
method of theMyAppDbContext.cs
file. These configurations can be modified by setting the values in the startup projects'Program.cs
files andXXXDbContextFactory.cs
file. These files are located in the startup projects (excludingXXX.DbMigrator
). -
Modify the table name prefix and schema of user tables in the
MyApp.Domain
project'sMyAppConsts.cs
file. TheDbTablePrefix
andDbSchema
constants can be modified to reflect the desired values.
Note: Make sure to carefully follow the steps and verify the changes to ensure the correct modification of table name prefixes and schemas.