Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Prompt: Add Migration
Purpose
Add an upgrade migration that seeds or changes data for existing installations — settings, localization resources, permissions, admin sitemap entries, scheduled tasks, or document shape.
Inputs Required
- Repository root.
- What the migration must change, and why an existing installation cannot work without it.
- Target
DbVersion(the version the change ships in). - Whether the change is additive or rewrites existing documents.
Steps
- Read
.ai/skills/database-review.mdand.ai/skills/mongodb-review.md. - Open
src/Modules/Grand.Module.Migration/Migrations/and read the highest existing version folder. Follow its file naming. - Decide the version folder. Create it only if the release version is new.
- Create a class implementing
IMigration:Priority— ordering inside the version. Resource and permission migrations usually run at0.Version—new DbVersion(major, minor).Identity— a newly generated GUID, never copied from another migration.Name— a short human-readable description including the version.UpgradeProcess(IServiceProvider)— returnsfalseon failure, and must not throw.
- For localization resources, add the strings to
App_Data/Resources/Upgrade/en_{version}.xmland callserviceProvider.ImportLanguageResourcesFromXml(...)rather than writing resources inline. - For permissions, admin sitemap, or scheduled tasks, follow the existing
MigrationSystemPermission,MigrationUpdateAdminSiteMap, andMigrationScheduleTasksfiles in the nearest version folder. - Bump the DB version with a
MigrationUpgradeDbVersion_{version}class when introducing a new version folder. - Verify the migration is idempotent: running it twice must not duplicate data or overwrite operator changes.
Mandatory Rules
Identitymust be unique across the whole repository — the migration runner uses it to record what already ran.- A migration must never throw; catch and return
false. - A migration must be idempotent — check for existing records before inserting.
- A migration must not delete operator-owned data unless that is explicitly the requested change.
- Resource changes go through the upgrade XML file, not through hardcoded strings in the migration.
- New settings must be added with defaults that preserve existing behavior for upgraded stores.
- Do not reuse a
DbVersionthat has already shipped for a behavior change; add a new migration in the current version instead.
Output Format
- Migration: class name, version, priority, identity GUID.
- What it seeds: settings, resources, permissions, sitemap, or tasks.
- Idempotency: exactly how a second run is made a no-op.
- Rollback: what an operator has to do if this migration is wrong.
- Validation: build and test results.