O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Model as Code (Code First)

Developers often prefer to work with code, and the EF Code First model is a recognition of that fact. Code First allows you to write code that defines your model (tables and relationships). You can then easily work with your model to get data, update it, and save it back to the database.

Code First can be used to target an existing database or generate a database directly from the code model. Of course, you can also use the Visual Studio tools to generate a Code First model based on an existing database.

To write a Code First model in a given project, you start by adding appropriate references to Entity Framework or use the NuGet package manager to install the latest version of EF and add it to your project. Once your ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required