Code Based Code First Migration
How to implement Code First Migrations without Package Manager Console commands. I want to implement Code First Migrations logic by using code. I don't want to write Following commands
PM > Enable-Migrations PM > Add-Migration PM > Update-Database
Please tell me the best practice.
Thanks in advance
Have a look at using the migrate.exe tool that is supplied when you install EF package.
You could theoretically call this from your code.
I'm not sure why you would be adverse to the first two, but the last I totally understand. You are looking for the DBMigrator class. You can use this to check how many migrations need to be run, and do the migration to any version. If you can do it with Update-Database, you can do it in code. I've referenced a similar example below.