Beginner's Guide to Entity Framework

原文地址:http://msdn.microsoft.com/en-us/data/ee712907

Introduction

The articles on this page will help you get started with the current version of Entity Framework. You can also check out Past Versions of Entity Framework.

Entity Framework has three developer workflows to help you access data in your application:

  • Code First – As the name suggests this approach is all about code. You write the classes that make up your domain model. A set of conventions map these classes to a database schema but you can provide additional mapping using code. Code First can map to an existing database or generate a database schema for you based on your model and mapping. If you are targeting an existing database the EF Power Tools can help you get started by generating basic classes and mapping for you.
  • Model First – You build your model using ‘boxes and lines’ in the Entity Model Designer. Once you model is created the designer will generate a database schema for your model. The classes that make up your domain model are generated for you.
  • Database First – If you have an existing database this approach allows you to reverse engineer a ‘boxes and lines’ model in the designer. You can then tweak the shape of the model and how it maps to your existing database schema. The classes that make up your domain model are generated for you.

The Basics

If you want to dive right in, here are some simple walkthroughs that cover the basics:

If you’d rather watch a video or read an article these links show Entity Framework being used to build an MVC application. The content was put together for EF 4.1 but is still applicable to the current version of Entity Framework. Be sure to check out the Code First Migrations feature that wasn’t available when these videos were recorded.

Going Deeper

Are you ready to dive a little deeper? These links drill into specific Entity Framework features.

  • API Documentation View detailed documentation for the Entity Framework API surface
  • Entity Framework Power Tools These design time tools help automate some common developer tasks
  • Using the DbContext API A 12-part series that goes deep into the DbContext API
  • SQL Azure Federations and the Entity Framework Combining Entity Framework with SQL Azure Federations
  • Minimizing Connection Pool errors in SQL Azure Configure Entity Framework for more robust SQL Azure access
  • Validation (video|article) Use server-side validation to check for invalid data
  • Data Annotations and Code First (video|article) Use Annotations to modify a Code First model
  • Code First: Relationship Fluent API (video|article) Configure relationships in your Code First model using the Fluent API
  • Code First: Mapping Fluent API (video & article) Configure column and table mappings in your Code First model using the Fluent API
  • Change Tracker API (video & article) Learn how Entity Framework tracks changes to your objects and how you can use that information
  • Entity Framework and N-Tier Apps (video & article) Learn how to use WCF Data Services with Entity Framework
  • Windows Phone 7 and Entity Framework (article only) Create a data service and consume it from a Windows Phone 7 application
  • Code First: Database Initializers(video & article) Starting in EF 4.3Code First Migrationshas reduced the need to use database initializers, but the concepts from this link can be useful in some situations

Want to know more about what Entity Framework is, its history, and where it’s headed?

The Latest Preview

All the content you have seen so far is about the latest fully supported release of Entity Framework. We’d love for you to try out our latest preview and let us know what you think.

Find out how to get the latest preview on the Get It page.

The latest preview is Entity Framework 5 Release Candidate. Here are some useful links to get you started.

Where Next?

Want to dig deeper still, here are some good online resources.

Version History

The first two versions of Entity Framework shipped with the .NET Framework and had versions numbers that aligned with the version of the framework that they were included in (3.5 and 4). After EF 4 was released we started shipping independently and adopted the http://semver.org standard for semantic versioning.

Here is a quick summary of the Entity Framework releases and the features they added. This table includes all the fully supported releases of Entity Framework and the latest pre-release version.

Release Summary
EF 5 Release Candidate

This release includes the latest preview of features coming in the EF 5 and can be used in Visual Studio 2010 and Visual Studio 11 to write applications that target .NET 4.0 and .NET 4.5.

When targeting .NET 4.5 this release introduces some new features including enum support, table-valued functions, spatial data types and various performance improvements.

The Entity Framework Designer in Visual Studio 11 Beta also includes multiple-diagrams per model, coloring of shapes on the design surface and batch import of stored procedures.

(learn more about this release)

   
EF 4.3.1

This patch release included some bug fixes to the EF 4.3 release and introduced better LocalDb support for folks using EF 4.3 with Visual Studio 11.

(learn more about this release)

   
EF 4.3

The EF 4.3 release included the new Code First Migrations feature that allows a database created by Code First to be incrementally changed as your Code First model evolves.

(learn more about this release)

   
EF 4.2

This release includes bug fixes to the EF 4.1.1 release.

Because this release only included bug fixes it could have been the EF 4.1.2 patch release but we opted to move to 4.2 to allow us to move away from the date based patch version numbers we used in the 4.1.x releases and adopt the http://semver.org standard for semantic versioning.

(learn more about this release)

   
EF 4.1.1

In addition to bug fixes this patch release introduced some components to make it easier for design time tooling to work with a Code First model. These components are used by Code First Migrations (included in EF 4.3) and the EF Power Tools.

Note the NuGet package for this release has the version number 4.1.10715. We used to use date based patch versions before we decided to adopt the http://semver.org standard for semantic versioning.

(learn more about this release)

   
EF 4.1

The EF 4.1 release was the first to be published on NuGet. This release included the simplified DbContext API and the Code First workflow.

Note the NuGet package for this release has the version number 4.1.10331. We used to use date based patch versions before we decided to adopt the http://semver.org standard for semantic versioning.

(learn more about this release)

   
EF 4

This release was included in .NET Framework 4 and Visual Studio 2010. New features in this release included POCO support, lazy loading, testability improvements, customizable code generation and the Model First workflow.

Although it was the second release of Entity Framework it was named EF 4 to align with the .NET Framework version that it shipped with. After this release we started making Entity Framework available on NuGet and adopted semantic versioning since we were no longer tied to the ,NET Framework Version.

   
EF (or EF 3.5) The initial release of Entity Framework was included in .NET 3.5 SP1 and Visual Studio 2008 SP1. This release provided basic O/RM support using the Database First workflow.
原文地址:https://www.cnblogs.com/triggor/p/2596483.html