Abp: Create a single point to set default schema for Abp database tables.

Created on 3 Jul 2019  路  7Comments  路  Source: abpframework/abp

Default will be null (no specific schema). This should work with EF Core PMC commands and command line tools too, so it can't be a classic IOptions option. Probably will be a static property.

abp-framework feature

Most helpful comment

Implemented this. If you want to change the "Abp" prefix for all modules, you can set it in the beginning of your program (Program.cs would be a good point to guarantee it):

csharp AbpCommonDbProperties.DbTablePrefix = "MyPrefix";

This changes all Abp prefixes to MyPrefix. But notice that not all modules are using the Abp prefix. Examples are IdentityServer, Docs and Blog. This is by design and for these modules you should configure one by one (see below).

For a single module (overrides AbpCommonDbProperties.DbTablePrefix):

csharp AbpIdentityDbProperties.DbTablePrefix = "MyIdentityPrefix";

Set "" (empty string), not null if you don't want a prefix for these tables.

Will be available in v0.22 release.

All 7 comments

Hope it's the right place to ask the question:
How to change the default "Abp" prefix and "IdentityServer" prefix for the database tables in Abp 0.18? in Aspnetboilerplate it was "modelBuilder.ChangeAbpTablePrefix" in "OnModelCreating" method.

@hikalkan Any chance we can have this before 1.0? I need to integrate abp.io now that .NET Core 3.0 is out and waiting until 1.0 is a bit "scary". I see others have had a go and while I can implement that I need to know if what is presented with https://github.com/abpframework/abp/issues/1387#issuecomment-528392117 is "all of it"?

I will check to see what we can do for this in this week. We are trying to release v0.22 (the last version before 1.0) in the end of this week.

Implemented this. If you want to change the "Abp" prefix for all modules, you can set it in the beginning of your program (Program.cs would be a good point to guarantee it):

csharp AbpCommonDbProperties.DbTablePrefix = "MyPrefix";

This changes all Abp prefixes to MyPrefix. But notice that not all modules are using the Abp prefix. Examples are IdentityServer, Docs and Blog. This is by design and for these modules you should configure one by one (see below).

For a single module (overrides AbpCommonDbProperties.DbTablePrefix):

csharp AbpIdentityDbProperties.DbTablePrefix = "MyIdentityPrefix";

Set "" (empty string), not null if you don't want a prefix for these tables.

Will be available in v0.22 release.

Why not make this definition in .EntityFrameworkCore.DbMigrator project, it will make sense more.
Set it in the beginning of your program (Program.cs would be a good point to guarantee it), it means the project must be a startup project, then all Db Migrator could determine it?

Why not make this definition in .EntityFrameworkCore.DbMigrator project, it will make sense more

There is no .EntityFrameworkCore.DbMigrator, but you probably intented to write MyCompanyName.MyProjectName.DbMigrator

Doing it only in the DbMigrator is not enough. It truely creates tables, however, on runtime all modules will use their own dbcontext and will use default prefix if you don't set it for all your applications.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hikalkan picture hikalkan  路  3Comments

wocar picture wocar  路  3Comments

vfabregat picture vfabregat  路  3Comments

hitaspdotnet picture hitaspdotnet  路  3Comments

SmallShrimp picture SmallShrimp  路  3Comments