Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Migrations Getting Started with Using Migrations Enabling Migrations

I am not sure what I just did in this video. Did I migrate stuff from a server?

I am not sure what I just did in this video. Did I migrate stuff from a server?

2 Answers

Allan Clark
Allan Clark
10,810 Points

Code first migrations is a way to handle the database schema using C# code rather than dealing with the SQL itself. In other words, 'migration' refers to migrating from your C# Entity Framework code to the database server.

This video shows you how to do the initial setup of Entity Framework to get ready for code first migrations. If we are speaking just in terms of this video, the DB server has not come into play yet. The 'enable-migrations' command simply tells the .NET framework that this project will use code first migrations and enables the other commands that are associated with it.

Later you will use the 'update-database' command and that will be when your classes will be interpreted as a database schema and will 'migrate' into the database server. This will (in most cases) create a table per class with primary/foreign keys created to model the relation between your classes.

Hope this helps! Happy Coding!

Allan, I love you man! Thanks for spelling it out for me. The instructor talks fast without many pauses and slowing it down just annoys me and I can't focus on understanding what's being said and done. Also, I did bring this up with support, the learning track is being taught to do coding a certain way then switch to the right way then back too the wrong way. It kind of follows this path with the C# and SQL tracks.