EF5 Released
We are very pleased to announce the release of Entity Framework 5. EF5 is available as the Entity Framework NuGet package and is also included in Visual Studio 2012.
What’s New in EF5
EF 5 includes a number of new features and bug fixes to the EF4.3 release. Most of the new features are only available in applications targeting .NET 4.5, see the Compatibility section for more details.
- Enum support allows you to have enum properties in your entity classes.
- Spatial data types can now be exposed in your model using the DbGeography and DbGeometry types.
- The Performance enhancements that we recently blogged about.
- Code First will now detect if you have LocalDb or SQL Express available for creating new databases. Visual Studio 2012 includes LocalDb, whereas Visual Studio 2010 includes SQL Express.
- Code First will add tables to existing database if the target database doesn’t contain any of the tables from the model.
The EF Designer in Visual Studio 2012 also has some new features:
- 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.
- 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.
- Table-Valued functions in an existing database can now be added to your model.
- Batch import of stored procedures allows multiple stored procedures to be added to the model during model creation.
Get Started @ msdn.com/data/ef
The updated EF MSDN site includes a bunch of walkthroughs and videos to get you started with Entity Framework, including the new features in EF5.
What Changed Since the Release Candidate
You can see a list of bugs that we fixed since the EF5 RC on the EF CodePlex site.
The most notable change since RC is that new models created using the EF Designer in Visual Studio 2012 will now generate a derived DbContext and POCO classes by default. You can always revert to ObjectContext code generation if needed.
Compatibility
This version of the NuGet package is fully compatible with Visual Studio 2010 and Visual Studio 2012 and can be used for applications targeting .NET 4.0 and 4.5.
Some features are only available when writing an application that targets .NET 4.5. This includes enum support, spatial data types, table-valued functions and the performance improvements.
Need Help
Head to the EF MSDN site to find out how to get help with Entity Framework.
Entity Framework Team
Comments
Anonymous
August 15, 2012
I thought you guys are using SemVer. Is the assembly version 4.4 or 5.0?Anonymous
August 15, 2012
@Jarrett Vance - We are following SemVer, this is EF 5.0.0. One small implementation detail is that the EF5 assembly for .NET 4.0 has an assembly version of 4.4 (to avoid the CLR thinking that the .NET 4.0 and .NET 4.5 assemblies for EF5 are the same assembly). If you look at the file version or informational version of either assembly it is 5.0.0.Anonymous
August 15, 2012
Thanks, guys! Are providers for SQL Server Compact also published?Anonymous
August 15, 2012
Is the Self-Tracking Entities Template for EF 5 ready?Anonymous
August 15, 2012
@Mark - We're just sorting out the license for the STE templates. We expect to have them up later this week.Anonymous
August 15, 2012
After updating a project to target .NET 4.5 and reference EF 5, NotMapped stopped working as expected when NotMapped is applied to a property in a base class that is defined in a different assembly. Specifics are at stackoverflow.com/.../141172Anonymous
August 15, 2012
Is Entity Framework Power Tools Beta 2 compatible with VS2012? Can't seem to install it.Anonymous
August 15, 2012
Having trouble getting any information on if or when Azure will support .NET 4.5 and therefore EF 5. Does anyone know?Anonymous
August 15, 2012
Cool do you have any plans to support mono?Anonymous
August 16, 2012
@Eric J. – We’ll follow up on the Stack Overflow thread. @Patrick Tran – Yes, the Power Tools work with VS2012. If you’re having issues then startup a Stack Overflow thread with details. @Mark Broomfield – I know it’s coming but I don’t have any idea on the timeline sorry. @Volodymyr - Yep… it’s there in the latest release - tirania.org/.../Aug-13.html. One cool outcome from our open source move :)Anonymous
August 16, 2012
@Andrei Mazoulnitsyn - Yes, the EntityFramework.SqlServerCompact NuGet package will work with EF5.Anonymous
August 16, 2012
When using the designer, I think the properties on the generated classes should be virtual. Otherwise, you run into performance issues if you have a lot of objects in the context (I.e. it won't use change tracking proxies). For example, in a program that batch loads enttities. This wasn't an issue when using ObjectContext.Anonymous
August 16, 2012
The comment has been removedAnonymous
August 16, 2012
Nice. Any news about the release of EF 6 beta that will support TVF and SPROC for code first?Anonymous
August 16, 2012
The comment has been removedAnonymous
August 16, 2012
@Khaled - Not yet, we wanted to get EF5 shipped before we starting getting an EF6 beta release together. I'm not sure if the first beta will include sproc mappings in Code First because we haven't started implementing it yet.Anonymous
August 17, 2012
Great work guys! Question: Why does enum support require VS 2012 / 4.5 Framework targeting? What is the technical reason behind this?Anonymous
August 17, 2012
@Aaron - supporting enums required changes to the core EF library which is part of the .NET Framework. .NET Framework 4.5 contains a new version of System.Data.Entity.dll that has these changes whereas version shipped with .NET Framework 4 does not. Hence the requirement of .NET Framework 4.5Anonymous
August 19, 2012
The comment has been removedAnonymous
August 20, 2012
The comment has been removedAnonymous
August 20, 2012
The comment has been removedAnonymous
August 20, 2012
Don't know if it is appropriate to post it here, but would you please have a look of this bug? connect.microsoft.com/.../entity-framework-designer-ignores-nullability-specified-manually-when-update-model-from-databaseAnonymous
August 21, 2012
OK i understand now, but does this mean I still have to use EF 4? and can not move to EF5Anonymous
August 21, 2012
@TaicoDev - Correct, you will need to stay on EF4 in this scenario.Anonymous
August 21, 2012
@deerchao - We will look at your Connect bug and reply to it.Anonymous
August 23, 2012
Please give option for EF 5 installer or zip. Due to proxy issue I cannot install through NuGet.Anonymous
August 23, 2012
@Ashraf - If you log into http://nuget.org you can download the EF NuGet package - just go to the EF package page and there is a Download link. You can then either host a local feed docs.nuget.org/.../hosting-your-own-nuget-feeds, or the .nupkg file you get is just a zip, so you can rename it to a .zip and get the assembly. Note that if you extract the assembly you will lose the Package Manager Console commands, so we would recommend setting up a local feed.Anonymous
August 25, 2012
Thanks, One question: Other ORMs, (those not included in .Net class libraries) can be used in the project as a dll. Why we can't do the same with EF? why should we wait till the next .Net release? Or need to increase the .Net version requirement of the app?Anonymous
August 26, 2012
The comment has been removedAnonymous
August 28, 2012
When is the EntityObject T4 template going to be released to the VS Gallery? Becoming frustrated... stackoverflow.com/.../entity-framework-5-0-entityobject-generator-not-available-in-visual-studio-2012Anonymous
August 28, 2012
It seems EF5 likes to put dbo. into table names when creating key constraints. I've got a migration that's not being handled well, it's attempting to remove a constraint called: FK_dbo.Events_dbo.Courses_Course_Id There is one called: FK_Events_Courses_Course_Id which I presume EF4.1 made. Unfortunately this causes an SQL error, yet the migration thinks it's completed fine. Any ideas anyone?Anonymous
August 29, 2012
@Iain M Norman - Can you start a StackOverflow thread using the entity-framework tag and provide some more details about how to reproduce this issue.Anonymous
August 29, 2012
Is EF5 has been shipped with Unique Constraints as described in - blogs.msdn.com/.../unique-constraints-in-the-entity-framework.aspx ??????? Please confirm.Anonymous
August 30, 2012
@Morshed: Unfortunately unique constraints did not fit in EF5 release.Anonymous
August 31, 2012
I can't believe you guys still haven't fixed the depluralrization problem with entities that end with "Status".Anonymous
September 01, 2012
I don't think this is specific to Entity Framework 5. I had a field that used byte as a primary key. I don't know if this is good practice but it ran OK in SQL server and even in entity Framework. Once I converted my code to use Code First I ran into a problem to add new data to this table. When I run SaveChanges the application gives me an error. I debugged the code and found that SaveChanges is unable to generate the primary key for the newly added row. I didn't get this error when I was using edmx.Anonymous
September 03, 2012
All the changes are killing us. So many things have been moved around now that I have to refactor half our codebase in the db layer if we want to move to EF5. Right now I'm trying to find out where mergeoption disappeared to among other things...Anonymous
September 06, 2012
@zl1 – Improving the pluralization service was something that just didn’t fit into EF5. You can track the issue here entityframework.codeplex.com/.../183Anonymous
September 06, 2012
@James Portelli – By default Code First can only create a database that generates values for GUID and Integer columns. If you are using Migrations you can always use the Sql method to add some logic that sets up some logic to generate values for a Byte column in the database. If you don’t do this then you’ll need to set the value on new objects before saving.Anonymous
September 06, 2012
@efygbfkm – There shouldn’t be any required changes to move to EF5. I suspect you are referring to moving from ObjectContext to DbContext. This is optional and ObjectContext remains as a fully supported and valid option. Within the EF Designer, existing models that use ObjectContext will continue to do so unless you decide to switch over. New models will use DbContext by default but you can always swap to ObjectContext - msdn.microsoft.com/.../jj556581Anonymous
September 06, 2012
@Paul Marvin - I'll follow up on the StackOverflow thread shortly.Anonymous
September 08, 2012
Are compiled queries available with DbContext yet? It will be rather infuriating if it was left out yet again.Anonymous
September 10, 2012
@Kyle - Queries are now automatically compiled and cached.Anonymous
September 10, 2012
Thanks for your reply Rowan. I still have not started looking into programming WinRT applications for Windows 8. I would really love to but I hear that .NET data classes are not supported. Is there anything planned to bring entity framework to WinRT applications ?Anonymous
September 11, 2012
@James Portelli - Correct, EF isn't available in WinRT applications. We are looking at data access for WinRT at the moment and investigating if EF is the right thing to make available.Anonymous
September 11, 2012
Any example of using EF5 in WPF, with full client binding and data manipulation and changes rollback?Anonymous
September 11, 2012
Thanks Rowan. Very kind of you. I wonder why Microsoft didn't think about this before. What is an application without data ? Is there a way to handle data in WinRT at the moment ? I heard of OData but can this be used with SQL server ?Anonymous
September 12, 2012
@VRassouli - Here is an EF/WPF walkthrough msdn.microsoft.com/.../jj574514 That page doesn't address rollback, but you can use context.Entry(myObject).Reload() to revert to what is in the database. Alternatively you can set the current values to the original values using the techniques discussed on this page - msdn.microsoft.com/.../jj592677Anonymous
September 12, 2012
The comment has been removedAnonymous
September 12, 2012
I keep hearing (reading) that in the new EF5: "New models created using the EF Designer in Visual Studio 2012 will now generate a derived DbContext and POCO classes by default." "New models will use DbContext by default but you can always swap to ObjectContext" etc... and so on, but every time I create a new model, either generated from database or empty, the Code Generation Strategy is still set to "Deault" when created, and using ObjectContext/EntityObjects, no DbContext/POCOs. Do I need to configure this as a hidden default setting in VS 2012? Thanks for any advice!Anonymous
September 14, 2012
@Fernando Espinosa - You don't need to do any configuration, you should just get DbContext by default. If you aren't seeing this can you start up a StackOverflow thread with the entity-framework tag so that we can investigate why.Anonymous
September 17, 2012
EF5's Code First does not support sequences in SQL Server 2012.Anonymous
September 18, 2012
Anyone else having problems with the EntityObject T4 template not auto-compiling during save of the EDMX despite the "Transform Text Templates" option being true and the TT template being a dependent of the EDMX?Anonymous
September 18, 2012
@Paul Marvin - Is your EDMX in a folder? You are probably hitting this bug - entityframework.codeplex.com/.../453Anonymous
September 18, 2012
@Rowan Miller - yep, I think you're 100% correct, all of my models are under a Models folder as well as a model specific folder, thanks for the heads-upAnonymous
September 28, 2012
The comment has been removedAnonymous
October 01, 2012
@Sean Stenlund - EF doesn't have support at this stage, you would need to use a raw sql query to fetch the data msdn.microsoft.com/.../jj592907Anonymous
October 01, 2012
@Rowan Miller Thank you for the reply. Sounds like I should add it to the Feature Suggestions--if it isn't already there. Basically, I want to implement something similar to Azure Blob Storage without using Azure. Like I said, Azure is great, but we already have an investment in our own equipment and our storage/throughput is not substantial.Anonymous
October 03, 2012
So, basically, this release is useless with .NET 4.0 since there is nothing new and all features require 4.5? Very disappointing.Anonymous
October 04, 2012
@Georgij Sapkin - Yes, unfortunately with parts of EF still in the .NET Framework we needed to update them to implement the bigger features. So on .NET 4 you just get bug fixes and other minor improvements. The good news is that in EF6 everything will be moved into the out-of-band assembly and all the EF5 features will start working on .NET 4. In fact, that work is already checked into our code base.Anonymous
October 06, 2012
Any plans for an EF6 Beta?Anonymous
October 08, 2012
@Andre.Ziegler - No exact dates yet, but we are working on the release at the moment and I think we'll make it available in the next month or so. In the mean time you can use the nightly builds to check out some of the new features. blogs.msdn.com/.../ef-nightly-builds-available.aspxAnonymous
October 11, 2012
@Rowan Miller Per my question about FileTable above; I see how using raw SQL to fetch the data will work. However, if I'm using CodeFirst and add the FileTable in SQL, I'll have a mismatch between the model and the database. So, I should add the FileTable via a migration. Right? So what would the CreateTable() look like? Especially since you don't create fields in a FileTable. CreateTable("dbo.MyFileTable", c => new { ? }) Can you use raw SQL in a migration? Thanks for your help, SeanAnonymous
October 11, 2012
@Rowan Miller do the nightly builds work with VS2010 and .net 4.0? I want to try the enum support.Anonymous
October 12, 2012
@Andre.Ziegler - Yes, we haven't done much testing of it yet but in general it should work.Anonymous
October 12, 2012
@Sean Stenlund - The easiest approach is probably to use raw SQL, you can use the Sql(string) method in your migration to do this.Anonymous
November 01, 2012
I have a question about the EF Designer in VS2012. When I open a EDMX file which is created with VS2010 and EF4, the designer is no longer loaded I can only see the XML. How can I get the designer back?Anonymous
November 14, 2012
With the performance benefits of EF5, is it still beneficial to use the pre-generated views feature from EF Power Tools Beta 2?Anonymous
November 14, 2012
@Patrick Tran: Performance improvements in EF5 did not focus on view generation but on auto compiling queries and generating faster/smaller SQL queries. If you identified view generation causing your app to start slowly then you may want to try if it helps. If you see performance problems when the app is running it's unlikely that it is caused by view gen and using pre-generated view will probably not help.Anonymous
November 14, 2012
The comment has been removedAnonymous
November 19, 2012
@Andre.Ziegler - I believe we answered this question for you in another place, but I just wanted to reply here for folks reading these comments. This occurs when the EF Designer is not selected for installation when installing VS. Unfortunately the EF Designer isn't grouped under the most obvious headings, when doing a custom install of VS2012 either 'SQL Server Data Tools' or 'Web Developer Tools' must remain selected for the EF Designer to be installed.Anonymous
November 20, 2012
@Rowan Miller yes, Brice Lambson explained it on codeplex: entityframework.codeplex.com/.../401836 but this is confusing. Rename it to Database Development Tools in the next VS or better make an extra option to install the EF Designer.Anonymous
November 21, 2012
@Andre.Ziegler - We totally agree and will address it in the next release, we've opened this item to track the issue - entityframework.codeplex.com/.../673.Anonymous
November 21, 2012
@Rowan Miller ok :)Anonymous
December 07, 2012
We're currently using EF 4.1 code first with SQL Server 2005. Will we still see the improvements in performance for EF5 even though we're using an older version of SQL Server? Will EF6 continue to support SQL Server 2005?Anonymous
December 07, 2012
The comment has been removedAnonymous
December 16, 2012
Not bad, 5 versions to get to production-ready. Another 5 versions to catch up? weblogs.asp.net/.../differences-between-nhibernate-and-entity-framework.aspxAnonymous
April 23, 2013
i referened the ef5,used [RelatedTo],occur "The type or namespace name 'RelatedTo' could not be found" ,why?Anonymous
April 24, 2013
@The type or namespace name 'RelatedTo' could not be found - RelatedTo was an old attribute used in some early previews of Code First. In the final versions you use the InverseProperty and ForeignKey attributes. This page has a section that shows how to use them - msdn.microsoft.com/.../jj591583.Anonymous
May 08, 2013
I have a database with 800 tables.Im new with Entity Framework. Until know i wrote my custom classes by myself and i used ADO NET to communicate with SQL Server. My Questions are
- Can Entity framework manage a large database?
- Is it easy for maintainance?
- Must multi part my model? Thanks
- Anonymous
May 09, 2013
The comment has been removed - Anonymous
May 12, 2013
Thank you Rowan Miller ! I will read these articles!