Separate Migrations Project(Class Library) — Entity Framework Core
May 20, 2021
You may want to store your migrations in a different project than the one containing your ApplicationDbContext
. You can also use this strategy to maintain multiple sets of migrations, for example, one for development and another for release-to-release upgrades. I used Entity Framework core 5.0 and ASP.NET core Web Application 5.0
Steps
- Create a ASP.NET core web application, project name “Xaero”. Add another Class Library in same project name as “Xaero.DataLayer”
- Add a reference “Xaero.DataLayer” to “Xaero”.
- Move the migrations and model snapshot files to the class library.
- Configure the migrations assembly in “Xaero”. Goto ConfigureServices method in Startup.cs file
5. GitHub link for project.
6. Thank you for reading.
“A clever person solves a problem.
A wise person AVOIDS it.”