Click here to Skip to main content
15,885,767 members
Articles / .NET

What is New in Entity Framework 5?

Rate me:
Please Sign up or sign in to vote.
4.50/5 (2 votes)
14 Jul 2013CPOL3 min read 30.6K   7  
New features of the newly released Entity Framework 5 and significant improvements of the latest Entity Framework 5

Introduction

Here, I explain the newly released Entity Framework 5 new features and about the significant performance improvements of the latest Entity Framework 5.

What is New in Entity Framework 5?

1. Enum Support

2. Spatial Data Types 

  • Can now be exposed in your model using the DbGeography and DbGeometry data types 

3. Performance Enhancements

i. LINQ to Entities Query Repeat Execution Time

  • Repeat execution time of the same LINQ query has been reduced by around 600%
  • By using automatic compilation of LINQ to Entities queries
What is automatic compilation?
  • Now every LINQ to Entities query that you execute automatically gets compiled and placed in EF’s query cache.
  • Each additional time you run the query, EF will find it in its query cache and won’t have to go through the whole compilation process again.

Behind the scenes of Auto-Compiled Query Process in EF 5

Performance gain of EF 5 Hence Auto-Compiled Query Process

ii. End-to-End Performance

  • Performance tests that run a variety of operations designed to simulate the typical usage of a real-world application
  • Then 67% performance increases over EF 4
  • Just by upgrading the server to EF 5

"We aren’t done improving performance yet, but we’re excited about how much faster EF 5.0 is."

- The Microsoft Entity Framework Team

4. Code First will now detect if you have LocalDb available for creating new databases

  • Visual Studio 2012 includes LocalDb

What is LocalDb? 

  • Microsoft SQL Server 2012 Express LocalDB is an execution mode of SQL Server Express targeted to program developers
  • LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine

5. Code First will add tables to Existing Database

  • If the target database doesn’t contain any of the tables from the model

What is New in Entity Framework Designer in Visual Studio 2012?

1. DbContext code generation for new models

  • Means that any new models created using the EF Designer will generate a derived DbContext and POCO classes by default
  • You can always revert to ObjectContext code generation if needed
  • Existing models will not automatically change to DbContext code generation

2. Multiple-diagrams per model

  • Allows you to have several diagrams that visualize subsections of your overall model
  • Shapes on the design surface can also have coloring applied

3. Table-Valued functions

  • In an existing database can now be added to your model

4. Batch import of Stored Procedures

  • Allows multiple stored procedures to be added to the model during model creation

How to Install Entity Framework 5 for Visual Studio 2012 Solution?

Step 1. Open Visual Studio 2012 with your project.

Step 2. Right click your solution and then click Properties.

Step 3. Double check whether Your Target Framework is 4.5.

Step 4. Right click your solution and then click Manage NuGet Packages...

Step 5. Click Online Tab and then Type Entity Framework 5 on Search Box.

After that, Select EntityFramework and Click Install.

Step 6. Click I Accept.

Step 7. Finally, close the Manage NuGet Packages Screen.

That's it. You're done.

Conclusion

  • You saw how much of performance gain could be achieved by just updating the Application Server for Entity Framework 5 out of the box without doing anything to your existing Linq to Entity Queries.
  • It's simply amazing.
  • So try to use EF 5 with your projects and enjoy it.

References

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Freelancer
Sri Lanka Sri Lanka
Sampath Lokuge holds a Bachelor of Science degree in the Mathematics and Computer Science at the University of Colombo, Sri Lanka.

He possesses over 8 years of experience in constructing web applications using Microsoft Technologies including ASP.net MVC, C#, SQL Server, Web API, Entity Framework and also other web technologies such as HTML5, CSS3,jQuery and AngularJS.

Sampath has earned Microsoft certifications such as MCP, MCAD, MCSD and MCTS and very recently he has completed MS (Microsoft Specialist) for MVC 4 and MCSD (Windows Store Apps Using HTML5).

Besides that, he is an active blogger, writing about web and mobile development issues and promoting best practices.He also actively participates in online communities such as Code Project and StackOverflow.He himself is handling three communities, which are ASP.net MVC 5 With C# on Linkedin,Entity Framework 6 on G+ and Hybrid Mobile App with WinJS on Facebook.

Now, I am a 100% Freelancer. Smile | :)

Tech Blogs


Sampath Lokuge Tech Universe

Communities which I'm Handling :


Entity Framework 6

ASP.net MVC 5 With C#

Hybrid Mobile App with WinJS

Comments and Discussions

 
-- There are no messages in this forum --