C#C
C#3y ago
36 replies
cumslvt13

✅ What's the point of ModelSnapshot in ef core migrations

I'm trying to move my migrations to a separate projects in case I want to change a db provider. I've moved my existing migrations to the separate project and that's what I've got now:

Application.Core <-- ApplicationDbContext
Application.Migrations.MsSql <-- References Application.Persistence, contains migrations


In my Application.Core project I've added the following config for DI:

services.AddDbContext(o => o.UseSqlServer("connectionString"));


I didn't add x => x.MigrationsAssembly("WebApplication1.Migrations") call as it shown in the docs (https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/projects)

My questions is: how come EF still works even though it doesn't reference Migrations project where AppContextModelSnapshot is stored? And what are potential issues with my approach?
Was this page helpful?