Book Image

Entity Framework 4.1: Expert's Cookbook

By : Devlin Liles , Tim Rayburn
Book Image

Entity Framework 4.1: Expert's Cookbook

By: Devlin Liles , Tim Rayburn

Overview of this book

<p>Entity Framework 4.1 allows us to dive into the world of data access without having to write SQL statements. With the power to shape data access by your object model comes questions and this book holds the answers.</p> <p>Entity Framework 4.1: Expert's Cookbook holds many examples to help guide you through tough technical decisions and avoid technical landmines. The book will guide you from just using Entity Framework to enhancing the data access wizard.</p> <p>This book starts with examples that require some familiarity of object relational mappers, and then moves on to more advanced tasks. You will be guided through complex mapping scenarios, query definition, reusability, integration with other technologies, and architectural management. The approach is step-by-step and test driven so that it is focused as much as possible on solving problems and getting the most out of the time spent working through the book.</p> <p>Entity Framework 4.1: Expert's Cookbook is a must have for any .NET developer who uses Entity Framework, and wants better, cleaner, and more maintainable code.</p>
Table of Contents (15 chapters)
Entity Framework 4.1: Expert's Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Improving MVC 3 applications


In this recipe, we will work through a full MVC 3 application, using patterns and the Entity Framework to give a solid basis for any enterprise application.

Getting ready

We will be using the NuGet Package Manager to install the Entity Framework 4.1 assemblies.

The package installer can be found at http://nuget.codeplex.com/.

We will also be using a database for connecting to the data, and updating.

Open the Improving MVC 3 Applications solution in the included source code examples.

How to do it...

  1. We start off with a couple of tests that will make sure that our controller and our repository work the way that we intend. We need to add a new C# test class named ControllerTests with the following code:

    using System.Collections.Generic;
    using System.Web.Mvc;
    using BusinessLogic;
    using BusinessLogic.Interfaces;
    using DataAccess.Queries;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Rhino.Mocks;
    using UI.Controllers;
    
    namespace Test
    {
      [TestClass]
      public...