Open aloksharma1 opened 2 weeks ago
Hello Team,
Any update on this issue, fyi i found the possible cause of this issue that looks like ModelSnapshot
is null even after loading the existing migration assemblies in memory i checked it using var loadedMigrations = context.GetService<IMigrationsAssembly>();
. is there any way to update snapshot manually/programatically after loading the assembly, i had the impression that once we register the old migrations in IMigrationsAssembly
implementation it will be taken care of automatically.
Ask a question
Hello, i am trying to setup automatic migrations on runtime for our internal project needs, i am able to generate/migrate correct migrations from dynamically added models on runtime following these issues #6806 #9339 #10872. the problem is i can't generate the correct migrations a second time when there is already some history in __EFMigrationsHistory snapshots, in which case the new migration code and snapshot should avoid existing model in table. But i am always getting same migrations not the differed version.
Include your code
my code is a bit complex, but the scaffolder setup is here:
i have also implemented
IModelCacheKeyFactory
like this:the db context is here:
Here is my MigrationsAssembly implementation , inspired from this article https://www.thinktecture.com/en/entity-framework-core/changing-db-migration-schema-at-runtime-in-2-1/:
I am saving existing migrations as assemblies for future migrations, and i can see it loaded in snapshot model but scaffolder still generates the whole model every time ending in error like
Microsoft.Data.SqlClient.SqlException: 'There is already an object named 'Orders' in the database.'
. thats the issue.Include provider and version information
EF Core version: 8.0.6 Database provider: Microsoft.EntityFrameworkCore.SqlServer, want to keep it db agnostic Target framework: .NET 8.0 Operating system: Win 11 IDE: VS Code/ Visual Studio?