I have created new module and add each project references to main application project like application into application, ef into ef module. When I add migration with module dbContext then It throws error that no dbContext was found. The startup project is main host application and selected project is main entity framework module.
- ABP Framework version: v8.3.0
- UI Type: Angular
- Database System: EF Core
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
- Steps to reproduce the issue:
10 Answer(s)
-
0
hi
When I add migration with module dbContext then It throws error that no dbContext was found. The startup project is main host application and selected project is main entity framework module.
Please share the command, execution folder and exception details.
Can you try to run
dotnet ef migrations add TestName
in your application ef core project?Thanks
-
0
Execution command : dotnet ef migrations add TestName Folder: Ef core module in main application
Migration run successfully but only with abp entities, not module entity. I have add reference of module ef core in main ef core module and also add DependsOn ef core module ref to main ef core module.
Do I need to do any other configuration to add module entities migration?
-
0
hi
You need to call
builder.ConfigureYourModule();
in theOnModelCreating
method of your applicationDbContext
class. -
0
I have already called builder.ConfigureYourModule(); in module class, If I add builder.ConfigureYourModule(); in main application ef core module then it will create entities in same database, not in module database. Right?
-
0
hi
There is no module database. Only apps have a database.
https://github.com/abpframework/abp/blob/dev/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDbContext.cs#L32
https://github.com/abpframework/abp/blob/dev/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictDbContextModelCreatingExtensions.cs#L12
-
0
I mean one apps can have multiple databases connection string, Like If I want abp audit log in different database then we can configure that same way, I want different database for custom module. One is default connection string and ModuleConnectionString.
public static class ModuleDbProperties { public static string DbTablePrefix { get; set; } = "Module"; public static string? DbSchema { get; set; } = null; public const string ConnectionStringName = "Module"; }
-
0
I have add builder.ConfigureYourModule() and migration is updating default database not module database.
-
0
I want different database for custom module. One is default connection string and ModuleConnectionString.
See https://abp.io/docs/latest/framework/fundamentals/connection-strings https://abp.io/docs/latest/framework/data/entity-framework-core/migrations
-
0
However, this can work only if the audit log database with the given connection string is available. So, you need to create the second database, create audit log tables inside it and maintain the database tables. No problem if you manually do all these. However, the recommended approach is the code first migrations. One of the main purposes of this document is to guide you on such database separation scenarios.
Ok, I understand, The migration for module can be manage by module itself, not the application.
-
0
: )