Learn your way! Get started

Entity Framework 6.1, Part 6 of 6: Code-First Dev

with expert Don Kiely


Watch trailer


Course at a glance

Included in these subscriptions:

  • Dev & IT Pro Video
  • Dev & IT Pro Power Pack

Release date 2/2/2015
Level Advanced
Runtime 3h 23m
Closed captioning Included
Transcript Included
eBooks / courseware N/A
Hands-on labs N/A
Sample code Included
Exams Included


Enterprise Solutions

Need reporting, custom learning tracks, or SCORM? Learn More



Course description

This course will start by covering how code-first works by default, which will probably work for most applications early in their development cycle. But when you’re ready to deploy the application to a production server, or need more flexibility in how Entity Framework creates a database. You’ll see how to create a code-first model and create a database from it, and see an application that makes use of it to maintain data in the database. You’ll also learn how to customize the database using both data annotations and the DBModelBuilder API, which lets you write code instead of use data annotations. Last you’ll see how code migrations is a newer feature of code first that goes beyond just deleting and recreating the database when the model changes.

Prerequisites

This course assumes that you are experienced with relational database design and programming concepts. Entity Framework is all about data access, and the course doesn’t spend any time on data fundamentals. You’ll also need a good understanding of object-oriented programming in C#, so that you know how to use the entity data objects that Entity Framework generates from your data model. You’ll also need to have a working knowledge of Language INtegrated Queries (LINQ) in C#. The course uses Entity Framework with various SQL Server databases, so you should know enough about SQL Server to know how to perform various tasks and be able to connect to a database. But you don’t need deep knowledge of SQL Server to use Entity Framework productively. You should have already viewed the Entity Framework 6.1: SQL Server Features course before taking this course.

Learning Paths

This course will help you prepare for the following certification and exam:
MCSD: Web Applications
70-487: Developing Windows Azure and Web Services

This course is part of the following LearnNowOnline SuccessPaths™:
Accessing Data Services for Win Dev
Accessing Data Services

Meet the expert

Don Kiely is a featured instructor on many of our SQL Server and Visual Studio courses. He is a nationally recognized author, instructor, and consultant specializing in Microsoft technologies. Don has many years of teaching experience, is the author or co-author of several programming books, and has spoken at many industry conferences and user groups. In addition, Don is a consultant for a variety of companies that develop distributed applications for public and private organizations.

Course outline



Domain-Centric Modeling

Creating A Model (33:54)
  • Introduction (01:51)
  • Domain-Centric Modeling (01:11)
  • Using Code-First (01:38)
  • Creating and Using a Model (02:14)
  • Demo: Ordering Model (04:43)
  • Demo: Address & Order (05:13)
  • Demo: Navigation Properties (04:31)
  • Demo: Ordering Context (05:37)
  • Demo: Connection (05:00)
  • Summary (01:52)
Model in ASP.NET MVC App (23:00)
  • Introduction (01:09)
  • Demo: Scaffold (06:02)
  • Demo: Add View (03:55)
  • Demo: Create (05:06)
  • Demo: Add Customer (06:16)
  • Summary (00:30)

Updating, Changing and Seeding

Run App and Explore Data (15:57)
  • Introduction (01:07)
  • Demo: Run App (05:24)
  • Demo: Create Database (03:54)
  • Demo: Explore Data (04:37)
  • Summary (00:52)
Update and Delete Customers (22:41)
  • Introduction (00:23)
  • Demo: Details (04:33)
  • Demo: Update Customer (05:16)
  • Demo: Add View (02:18)
  • Demo: Delete User (05:33)
  • Demo: Run Application (04:15)
  • Summary (00:20)
Changing the Model (14:53)
  • Introduction (00:28)
  • Demo: Change the Model (03:29)
  • Changing the Model (04:35)
  • Demo: Database Re-creation (05:47)
  • Summary (00:33)
Seeding the Database with Data (12:55)
  • Introduction (01:07)
  • Demo: Ordering Initializer (05:08)
  • Demo: Ordering Initializer Cont (01:25)
  • Demo: Change the Model (04:26)
  • Summary (00:46)

Databases and Migrations

Customizing the Database (28:36)
  • Introduction (01:24)
  • Customizing the Database (02:41)
  • Conventions (02:42)
  • Data Annotations (01:12)
  • Demo: Primary Keys (04:57)
  • Demo: Annotations (04:42)
  • Demo: Override Names (05:14)
  • Demo: Using Annotations (05:25)
  • Summary (00:16)
Db Model Builder API (15:50)
  • Introduction (01:13)
  • Demo: Remove Convention (04:04)
  • Config Properties & Entities (01:30)
  • Demo: Property Method (04:32)
  • Demo: Change Column Name (03:35)
  • Summary (00:53)
Code First Migrations (35:15)
  • Introduction (01:55)
  • Code-First Migrations (00:38)
  • Migration Implementation (01:13)
  • Demo: Package Manager (04:44)
  • Demo: Migration Object (05:27)
  • Demo: Automatic Migration (01:43)
  • Demo: Change Initialization (04:28)
  • Demo: Database Schema (04:00)
  • Demo: Data Loss (02:08)
  • Demo: Accept Data Loss (03:20)
  • Demo: Add Model Class (04:49)
  • Summary (00:43)