Programming Entity Framework: Code First [NOOK Book]


Take advantage of the Code First data modeling approach in ADO.NET Entity Framework, and learn how to build and configure a model based on existing classes in your business domain. With this concise book, you’ll work hands-on with examples to learn how Code First can create an in-memory model and database by default, and how you can exert more control over the model through further configuration.

Code First provides an alternative to the ...

See more details below
Programming Entity Framework: Code First

Available on NOOK devices and apps  
  • NOOK Devices
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK Study
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
$10.49 price
(Save 30%)$14.99 List Price


Take advantage of the Code First data modeling approach in ADO.NET Entity Framework, and learn how to build and configure a model based on existing classes in your business domain. With this concise book, you’ll work hands-on with examples to learn how Code First can create an in-memory model and database by default, and how you can exert more control over the model through further configuration.

Code First provides an alternative to the database first and model first approaches to the Entity Data Model. Learn the benefits of defining your model with code, whether you’re working with an existing database or building one from scratch. If you work with Visual Studio and understand database management basics, this book is for you.

  • Learn exactly what Code First does—and does not—enable you to do
  • Understand how property attributes, relationships, and database mappings are inferred from your classes by Code First
  • Use Data Annotations and the Fluent API to configure the Code First data model
  • Perform advanced techniques, such as controlling the database schema and overriding the default model caching

This book is a continuation of author Julia Lerman’s Programming Entity Framework, widely recognized as the leading book on the topic.

Read More Show Less

Product Details

  • ISBN-13: 9781449323844
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 11/18/2011
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 194
  • Sales rank: 613,890
  • File size: 3 MB

Meet the Author

Julia Lerman is the leading independent authority on the Entity Framework and has been using and teaching the technology since its inception in 2006. She is well known in the .NET community as a Microsoft MVP, ASPInsider, and INETA Speaker. Julia is a frequent presenter at technical conferences around the world and writes articles for many well-known technical publications including the Data Points column in MSDN Magazine.

Julia lives in Vermont with her husband, Rich, and gigantic dog, Sampson, where she runs the Vermont.NET User Group. You can read her blog at and follow her on Twitter at julielerman.

Rowan Miller is based in Seattle, Washington and works as a Program Manager for the ADO.Net Entity Framework team at Microsoft. Prior to moving to the US he resided in the small state of Tasmania in Australia. Rowan speaks at technical conferences and blogs at Outside of technology Rowan's passions include snowboarding, mountain biking, horse riding, rock climbing and pretty much anything else that involves being active. The primary focus of his life, however, is to follow Jesus.

Read More Show Less

Table of Contents

Contents of This Book;
Conventions Used in This Book;
Using Code Examples;
Safari® Books Online;
How to Contact Us;
Chapter 1: Welcome to Code First;
1.1 Modeling with EF Before Code First;
1.2 Inception of Code First;
1.3 Getting Code First to Developers in Between .NET Releases;
1.4 Writing the Code…First;
1.5 Managing Objects with DbContext;
1.6 Using the Data Layer and Domain Classes;
1.7 Getting from Classes to a Database;
1.8 Working with Configuration;
1.9 Creating or Pointing to a Database;
1.10 What Code First Does Not Support;
1.11 Learning from This Book;
Chapter 2: Your First Look at Code First;
2.1 Introducing EF to the Domain Classes;
2.2 Putting the Pieces Together in an Example;
2.3 Overriding Convention with Configurations;
2.4 Understanding How Model Changes Impact Database Initialization;
2.5 Configuring Code First with the Fluent API;
2.6 Summary;
Chapter 3: Using Conventions and Configurations for Property Attributes;
3.1 Working with Property Attributes in Code First;
3.2 Mapping Keys;
3.3 Configuring Database-Generated Properties;
3.4 Configuring TimeStamp/RowVersion Fields for Optimistic Concurrency;
3.5 Configuring Non-Timestamp Fields for Concurrency;
3.6 Mapping to Non-Unicode Database Types;
3.7 Affecting the Precision and Scale of Decimals;
3.8 Working with Complex Types in Code First;
3.9 Configuring Properties of Complex Types;
3.10 Summary;
Chapter 4: Using Convention and Configuration for Relationships;
4.1 Working with Multiplicity;
4.2 Working with Foreign Keys;
4.3 Working with Inverse Navigation Properties;
4.4 Working with Cascade Delete;
4.5 Exploring Many-to-Many Relationships;
4.6 Working with Relationships that Have Unidirectional Navigation;
4.7 Working with One-to-One Relationships;
4.8 Summary;
Chapter 5: Using Conventions and Configurations for Database Mappings;
5.1 Mapping Class Name to Database Table and Schema Name;
5.2 Mapping Property Names to Database Columns;
5.3 Allowing Multiple Entities to Map to a Single Table: aka Table Splitting;
5.4 Mapping a Single Entity Across Multiple Tables;
5.5 Controlling Which Types Get Mapped to the Database;
5.6 Understanding Property Mapping and Accessibility;
5.7 Preventing Properties from Being Included in the Model;
5.8 Mapping Inheritance Hierarchies;
5.9 Working with Abstract Base Classes;
5.10 Mapping Relationships;
5.11 Summary;
Chapter 6: Controlling Database Location, Creation Process, and Seed Data;
6.1 Controlling the Database Location;
6.2 Working with Database Initialization;
6.3 Using Database Initializers to Seed Data;
6.4 Using Database Initialization to Further Affect Database Schema;
6.5 Summary;
Chapter 7: Advanced Concepts;
7.1 Mapping to Nontable Database Objects;
7.2 Removing Conventions;
7.3 Taking Control of Model Caching;
7.4 Working with the EdmMetadata Table;
7.5 Using Code First with ObjectContext;
7.6 Summary;
Chapter 8: What’s Coming Next for Code First;
8.1 Code First Migrations;
8.2 Entity Framework Power Tools;

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)