- ABP Framework version: v7.4.3
- UI Type: MVC
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
You describe the new database migration system here: https://blog.abp.io/abp/ABP.IO-Platform-7-4-RC-Has-Been-Published I like to auto migrate my application on startup, however, the description is not total clear for me. Can you please bring an example how to implement it in a normal MVC application?
5 Answer(s)
-
0
If you are using abp suite after performing package install at front end it will prompt on abp suite browser window like you want to add migration. If going through command line then you can do manually https://docs.abp.io/en/commercial/latest/getting-started-running-solution?UI=MVC&DB=EF&Tiered=No#running-the-dbmigrator
-
0
I know, however, in the post mentioned above you describe the new feature "In this version, ABP Framework provides base classes and events to migrate the database schema and seed the database on application startup. This system works compatibly with multi-tenancy and whenever a new tenant is created or a tenant's database connection string has been updated, it checks and applies database migrations for the new tenant state."
I like to have an practical example here how to implement it :)
-
0
-
0
In the article you describe: < In this version, ABP Framework provides base classes and events to migrate the database schema and seed the database on application startup. This system works compatibly with multi-tenancy and whenever a new tenant is created or a tenant's database connection string has been updated, it checks and applies database migrations for the new tenant state.
This system is especially useful to migrate databases for microservices. In this way, when you deploy a new version of a microservice, you don't need to manually migrate its database.
You need to take the following actions to use the database migration system:
Create a class that derives from EfCoreRuntimeDatabaseMigratorBase class, override and implement its SeedAsync method. And lastly, execute the CheckAndApplyDatabaseMigrationsAsync method of your class in the OnPostApplicationInitializationAsync method of your module class. Create a class that derives from DatabaseMigrationEventHandlerBase class, override and implement its SeedAsync method. Then, whenever a new tenant is created or a tenant's connection string is changed then the SeedAsync method will be executed. >
I like to see a practcal implementation how to implement the described steps in a MVC application.
-
0
In the article you describe: < > In this version, ABP Framework provides base classes and events to migrate the database schema and seed the database on application startup. This system works compatibly with multi-tenancy and whenever a new tenant is created or a tenant's database connection string has been updated, it checks and applies database migrations for the new tenant state.
This system is especially useful to migrate databases for microservices. In this way, when you deploy a new version of a microservice, you don't need to manually migrate its database.
You need to take the following actions to use the database migration system:
Create a class that derives from EfCoreRuntimeDatabaseMigratorBase class, override and implement its SeedAsync method. And lastly, execute the CheckAndApplyDatabaseMigrationsAsync method of your class in the OnPostApplicationInitializationAsync method of your module class. Create a class that derives from DatabaseMigrationEventHandlerBase class, override and implement its SeedAsync method. Then, whenever a new tenant is created or a tenant's connection string is changed then the SeedAsync method will be executed.
I like to see a practcal implementation how to implement the described steps in a MVC application.
Hi, here is the issue of this feature: https://github.com/abpframework/abp/pull/16862
You need to do the steps mentioned in the issue and then execute the
CheckAndApplyDatabaseMigrationsAsync
method of your class that derives from theEfCoreRuntimeDatabaseMigratorBase
class in theOnPostApplicationInitializationAsync
method of your module class: