From the course: Using Entity Framework Core with Legacy Databases
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Migrations against an existing database
From the course: Using Entity Framework Core with Legacy Databases
Migrations against an existing database
- [Instructor] Migrations are a key feature of Vanity framework. They allow a source controlled revertable version way, to know that the database schema and the schema that the code expects line up. I've opened a command line window, and navigated to the directory that contains our project. To begin using migrations, with our existing database, we'll type dot net ef, migrations, add, and I'll name this one initial. Now that that's completed, let's open up the project, and see what's been added. We have a new folder named migrations. Within the migrations folder, we have three files. The first file that we'll look at is the context model snapshot. The context model snapshot rolls all of the model definitions, data annotations, and conventions into a single complete database definition. This file is regenerated regularly, so we shouldn't make any changes to it, but it can be worthwhile to view this file, since it contains the full definition of our database, Vanity framework, we can use…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.