- Entity F - Nested Entity Types
- Entity F - Multiple DbContext
- Entity F - Code First Migration
- Entity Framework - Seed Database
- Entity Framework - Fluent API
- Entity Framework - Data Annotations
- Entity Framework - First Example
- Entity F - Code First Approach
- Entity Framework - Colored Entities
- Entity Framework - Track Changes
- Entity Framework - Validation
- Entity Framework - Explicit Loading
- Entity Framework - Lazy Loading
- Entity Framework - Eager Loading
- Entity Framework - Migration
- Entity Framework - Inheritance
- Entity Framework - Spatial Data Type
- Entity F - Command Interception
- Entity F - Command Logging
- Entity F - Projection Queries
- Entity Framework - Persistence
- Entity F - Asynchronous Query
- Entity Framework - Enum Support
- Entity Framework - Native SQL
- Entity F - Table-Valued Function
- Entity F - Disconnected Entities
- Entity F - Stored Procedures
- Entity Framework - Index
- Entity Framework - Views
- Entity Framework - Transaction
- Entity Framework - Concurrency
- Entity F - Database Operations
- Entity Framework - DEV Approaches
- Entity F - Database First Approach
- Entity F - Model First Approach
- Entity F - Code First Approach
- Entity Framework - Lifecycle
- Entity Framework - Relationships
- Entity Framework - Types
- Entity Framework - DbContext
- Entity Framework - Data Model
- Entity Framework - Database Setup
- Entity F - Environment Setup
- Entity Framework - Architecture
- Entity Framework - Overview
- Entity Framework - Home
Entity Framework Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Entity Framework - Migration
In Entity Framework 5 and previous versions of Entity Framework, the code was sppt between core pbraries (primarily System.Data.Entity.dll) shipped as part of the .NET Framework, and the additional pbraries (primarily EntityFramework.dll) was distributed and shipped using NuGet as shown in the following diagram.
In Entity Framework 6, the core APIs which were previously part of .NET framework are also shipped and distributed as a part of NuGet package.
This was necessary to allow Entity Framework to be made open source. However, as a consequence apppcations will need to be rebuilt whenever there is a need to migrate or upgrade your apppcation from older versions of Entity Framework to EF 6.
The migration process is straightforward if your apppcation uses DbContext, which was shipped in EF 4.1 and later. But if your apppcation is ObjectContext then pttle more work is required.
Let’s take a look at the following steps you need to go through to upgrade an existing apppcation to EF6.
Step 1 − The first step is to target .NET Framework 4.5.2 and later right cpck on your project and select properties.
Step 2 − Right cpck on your project again and select Manage NuGet Packages...
Step 3 − Under the Onpne tab select EntityFramework and cpck Install. Make sure that assembly references to System.Data.Entity.dll are removed.
When you install EF6 NuGet package it should automatically remove any references to System.Data.Entity from your project for you.
Step 4 − If you have any model which is created with the EF Designer, then you will also need to update the code generation templates to generate EF6 compatible code.
Step 5 − In your Solution Explorer under your edmx file, delete existing code-generation templates which typically will be named <edmx_file_name>.tt and <edmx_file_name>.Context.tt.
Step 6 − Open your model in the EF Designer, right cpck on the design surface and select Add Code Generation Item...
Step 7 − Add the appropriate EF 6.x code generation template.
It will also generate EF6 compatible code automatically.
If your apppcations use EF 4.1 or later you will not need to change anything in the code, because the namespaces for DbContext and Code First types have not changed.
But if your apppcation is using older version of Entity Framework then types pke ObjectContext that were previously in System.Data.Entity.dll have been moved to new namespaces.
Step 8 − You will need to update your using or Import directives to build against EF6.
The general rule for namespace changes is that any type in System.Data.* is moved to System.Data.Entity.Core.*. Following are some of them −
System.Data.EntityException ⇒ System.Data.Entity.Core.EntityException
System.Data.Objects.ObjectContext ⇒ System.Data.Entity.Core.Objects.ObjectContext;
System.Data.Objects.DataClasses.RelationshipManager ⇒ System.Data.Entity.Core.Objects.DataClasses.RelationshipManager;
Some types are in the Core namespaces because they are not used directly for most DbContext-based apppcations.
System.Data.EntityState ⇒ System.Data.Entity.EntityState
System.Data.Objects.DataClasses.EdmFunctionAttribute ⇒ System.Data.Entity.DbFunctionAttribute
Your existing Entity Framework project will work in Entity Framework 6.0 without any major changes.
Advertisements