A deep dive into using EF Core's `ExcludeFromMigrations()` to build plugin-based systems where each plugin owns its own database schema and migration timeline. Covers the three-layer architecture: host context excludes plugin tables while retaining query capability, plugin context owns its schema with isolated migration history tables, and the application layer handles cross-context data loading. Key gotchas include the FK navigation property bug (GitHub issue #23639) that causes spurious DROP/ADD FK operations, the need for `IDesignTimeDbContextFactory` per plugin, `MigrationsHistoryTable` isolation to prevent collision, and correct startup migration ordering. Also covers integration testing patterns and when to choose this pattern versus a unified context.

8m read timeFrom daily-devops.net
Post cover image
Table of contents
What ExcludeFromMigrations Does and Does Not DoThe FK Navigation GotchaLayer 1: Host Context Excludes Plugin TablesLayer 2: Plugin Context Owns Its TablesLayer 3: Cross-Context Data in the Application LayerStartup Migration OrderingIntegration TestingWhen to Use This Pattern vs. a Unified ContextThe Complete Picture
671 Impressions