I'm wondering if anyone knows how to add a migration through c# code.
I'm kinda new to code first migrations.
I've been playing about with the ToolingFacade class from System.Data.Entity.Migrations.Design.
With this class I can detect migrations, update from one migration to another, detect pending migrations. I can also scaffold a new migration, although I don't know how to "add" this migration to the migrations folder (with the changes in the model handled).
With a newly created scaffold migration, the C# code for this is held within a property. I could in theory create a file in the migrations directory and add this code to it (and then update the database using this migration). Although the pending model changes are not entered within the "up" and "down" methods.
I've also tried using power shell object within C#, using Add-Migration command etc, but they are not recognised as a known cmdlet.
What I want to do is the equivlant of the console command: Add-Migration "MigrationName" -ProjectName "ProjectName" .... in c#
Any help appreciated
Entity framework 4.3 run migrations at application start Does not answer my question. They answer how to update the database with an existing migration. I want to add a new migration, before updating it. By code
enable-migrationsfrom the NuGet Package Manager Console ?