I am just upgrading to v15.0.0. I would like to know how to disable automatic database migration in the web host. Thanks.
2 Answer(s)
-
0
Hi @gerryp
On the ASP.NET Zero side, the Web.Host project does not run automatic database migrations by default. In other words, when the application starts, there is no
Migrate()call or similar migration trigger mechanism executed automatically.Within Web.Host, only the seeding process is controlled. This is managed by the
SkipDbSeedflag insideAbpZeroTemplateEntityFrameworkCoreModule. IfSkipDbSeed = false, it only seeds data on top of the existing schema. This does not mean that migrations are executed.Database migration and initial setup operations are performed in two ways:
Migrator Console Application Migrations + seeding are executed together through the
MyCompanyName.AbpZeroTemplate.Migratorproject. This is the recommended approach for production environments.Install Endpoint The installer mechanism used during first time setup triggers the migration process.
Therefore, there is normally no need to disable automatic migration on the Web.Host side, because migrations are not executed there in the first place. If the goal is to disable the seeding process, setting
SkipDbSeed = trueis sufficient.You can also add the following technical recommendation at the end of your response:
If you want to completely disable seeding on the Web.Host side, you can set the
SkipDbSeedflag inside theAbpZeroTemplateWebHostModuleconstructor:public AbpZeroTemplateWebHostModule( IWebHostEnvironment env, AbpZeroTemplateEntityFrameworkCoreModule abpZeroTemplateEntityFrameworkCoreModule) { _env = env; _appConfiguration = env.GetAppConfiguration(); // Disable automatic seeding on Web.Host startup abpZeroTemplateEntityFrameworkCoreModule.SkipDbSeed = true; }This approach:
Prevents seed execution during Web.Host startup
Does not affect migration behavior (since Web.Host does not run migrations anyway)
If you have any questions, please do not hesitate to contact us.
If this explanation does not fully address your issue, feel free to share the situation with examples or provide a bit more detail. This will allow us to give you a clearer, more specific, and tailored response.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
This was very helpful and thorough. Thanks you
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)