The information in this post is out of date.
Visit msdn.com/data/ef for the latest information on current and past releases of EF.
We are excited to announce the final Release to Web (RTW) of Microsoft ADO.NET Entity Framework 4.1 (EF 4.1). This is a fully supported, go-live release.
What’s in EF 4.1?
ADO.NET Entity Framework 4.1 introduces two new features:
- The DbContext API is a simplified abstraction over ObjectContext and a number of other types that were included in previous releases of the ADO.NET Entity Framework. The DbContext API surface is optimized for common tasks and coding patterns. DbContext can be used with Database First, Model First and Code First development.
- Code First is a new development pattern for the ADO.NET Entity Framework and provides an alternative to the existing Database First and Model First patterns. Code First is focused around defining your model using C#/VB.NET classes, these classes can then be mapped to an existing database or be used to generate a database schema. Additional configuration can be supplied using Data Annotations or via a fluent API.
Getting EF 4.1
ADO.NET Entity Framework 4.1 is available in a couple of places:
- Download the stand alone installer
- Add the ‘EntityFramework’ NuGet package to your project
Note: The NuGet package only includes the EF 4.1 runtime and does not include the Visual Studio item templates for using DbContext with Model First and Database First development.
Getting Started
There are a number of resources to help you get started with EF 4.1:
- ADO.NET Entity Framework page on the MSDN Data Developer Center
There is lots of great new content on this site, including ‘Getting Started’ videos for the new features in EF 4.1 - MSDN Documentation
- ADO.NET Entity Framework Forum
- Code First walkthrough
- Model First / Database First walkthrough
Non-English Releases?
This initial release only includes US English IntelliSense, exception messages and Visual Studio item templates. In approximately a month we will also be releasing a series of ‘Language Packs’ that will add localized versions of these resources to an existing EF 4.1 install. These language packs will be available for the same language set as Visual Studio 2010.
Support
This release can be used in a live operating environment subject to the terms in the License Terms. The ADO.NET Entity Framework Forum can be used for questions relating to this release.
What Changed Since EF 4.1 Release Candidate?
The new features in ADO.NET Entity Framework 4.1 were previously available in a Release Candidate. The changes between RC and RTW are mostly bug fixes with one exception:
- Change of default length for non-key string and binary columns from ‘128’ to ‘Max’. SQL Compact does not support ‘Max’ columns, when running against SQL Compact an additional Code First convention will set a default length of 4000. There are more details about the change included in a recent blog post.
What’s Not in EF 4.1?
There are a number of commonly requested features that did not make it into EF 4.1. We appreciate that these are really important to you and our team has started work on a number of them already, we will be reaching out for your feedback on these features soon:
- Enum support
- Spatial data type support
- Stored Procedure support in Code First
- Migration support in Code First
- Customizable conventions in Code First
Thank You
It has been great to have so much community involvement helping us drive the new features in EF 4.1. We thank you for giving us your valuable input and look forward to working together on the next release.
ADO.NET Entity Framework Team
Congratulations on EF 4.1 RTW Release !!
You guys did a great job.
Nice work! Now it's time to think of extensibility, don't you think?
– Support for other id generators (sequence, guid, hilo, etc)
– Support for events (before/after delete/insert/update, etc)
– Other mapping options (map, set, bag, list, etc)
Just MHO!
Excellent news – +1 for rjperes' thoughts too (especially events + caching).
Love the fact that you're being open about what's not in this release too. Are there plans to be more transparent with your schedule for these next features…(especially given what you've said about enum/spatial support requiring a core update and I'm guessing stored proc support/conventions/migrations not needing this) ?
Nice job, thank you! Now I need to find some training and refresh all knowledge )
Where is the change log that shows fixes and enhancements from 4.0 to 4.1 RTW? It is getting a bit exhausting looking at what has changed from RC to RTW, from CTP # to RC, etc… Is there a comprehensive listing somewhere? Thanks.
Great work … Looking forward to Enum support in the (near?) future!
Superb. I really like how Code First keeps my code nice and clean. The other design principles bloat the class structure and make working with an O/RM needlessly complex.
An adapted (read-only) class diagram which shows relations between classes, would come in handy for bigger projects. (To keep an overview over the entities).
Other than that, I hope the team finds a way to do more incremental updates. The core .NET lock-in isn't all that good for an O/RM framework.
Wow, you guys delivered earlier than promissed!
Well done!
I have to say Code First enhancement falls in the simple category. Creating software that is simple and intuitive is indeed the most difficult endeavor. Now if some author will write a 100 page book (not more), I will buy it.
Excellent job by the team !
Great work, the transparency, level of communication and community outreach, and the regular flow of previews has been a breath of fresh air. The mvc team and yourselves are really leading the way with keeping the devs happy
I get the following error after I try to add DbContext generator to the project:
Error 1 Running transformation: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.IO.FileNotFoundException: Unable to locate file
Server stack trace:
at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolvePath(String path)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolvePath(String path)
— End of inner exception stack trace —
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.VisualStudio.TextTemplatingA05CE357D75C6B263192756D28314995.GeneratedTextTransformation.DynamicHost.ResolvePath(String path)
at Microsoft.VisualStudio.TextTemplatingA05CE357D75C6B263192756D28314995.GeneratedTextTransformation.MetadataLoader.TryCreateEdmItemCollection(String sourcePath, String[] referenceSchemas, EdmItemCollection& edmItemCollection)
at Microsoft.VisualStudio.TextTemplatingA05CE357D75C6B263192756D28314995.GeneratedTextTransformation.MetadataLoader.CreateEdmItemCollection(String sourcePath, String[] referenceSchemas)
at Microsoft.VisualStudio.TextTemplatingA05CE357D75C6B263192756D28314995.GeneratedTextTransformation.TransformText()
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result) 1 1
First of all congratulations on the final product….
Can you use Code first with silverlight? WCF RIA??
Could you provide some educational material on using IObjectContextadapter
using a connection string and some insight on using a stored procedure(I do know this is not finished..
I really am intrigued by your next edition on mapping stored procedures
to code first.
Thanks for a great ride, the journey to get to this point was a great learning experience! Now i just need to upgrade my projects to RTW and fireup the applications.
Can't wait for the next version previews
Best regards,
Alexandre
My current project is using the Devart Oracle Entity Framework provider with EF 4 support. Can you please explain how your releases fit in with that product? Can I use them in addition to Devart, or must I wait for Devart to add support…
Thank you.
Started using the RC with the Oracle beta EF driver and it's been working quite well. Congrats on the release!
Where is the code-first mapping (basic as well as advanced concepts) documentation? Please provide those links.
Thanks.
Thanks for the release! This should be a big help to us.
Do you have any updates on the migration features? Last post on this was back in October, so I hope migrations will be available soon…perhaps v4.2? 🙂
What's about the hierarchyid data type?
Dmitry, I got the same but model & database first instead of code first works for me.
With model first though the template is placing the namespaces in front of every class instead of just the beginning of the file which of course won't compile. At least it's easy to fix in the template move the namespaces before the foreach loop.
Really like EF Code First, but would like it a lot more if you could make it easier for people who work in a detached environment such as WCF: stackoverflow.com/…/ef-4-1-code-first-change-to-fk-value-not-updated-when-using-new-context-over-wc
Glad to see progress on EF.
However, I'm still waiting for a fix on this bug:
connect.microsoft.com/…/entity-framework-include-strings-are-arbitrarily-limited-to-a-path-of-depth-8
It happens also in this release (4.1). When can I expect a fix?
Any news on improvements to the model designer such as :-
– Split models (for larger projects).
– Accurate transfer of defaults from database schema to model.
– Enums
Pleasseee…. implement WillCascadeOnDelete with many-to-many… this is basic for a ORM
c'mon enums make your way into an EF release already (!)
How to map private field or private property to table column?
Feature expand with path was working in EF 4.0, but not implemented in EF 4.1
example:
works in EF 4.0 (with expand path)
http://localhost/odata/ArticleItems()?$filter=(ProjectId eq 1L) and IsRootNode&$orderby=DisplayOrder&$expand=Article/ArticleProperties
works in EF $.0 & 4.1 (without expand path)
http://localhost/odata/ArticleItems()?$filter=(ProjectId eq 1L) and IsRootNode&$orderby=DisplayOrder&$expand=Article
The Exception:
… …
<message xml:lang="en-US">Not Implemented</message>
– <innererror>
<message>Unable to create a constant value of type 'System.Collections.Generic.IEnumerable`1'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.</message>
<type>System.NotSupportedException</type>
.. …
Any ETA when this feature will be back?
Looking at that list of things still to do (which is way too short BTW), all I can say is keep going guys. A few more revs and you might have a data access technology worth using.
i have vs2010 ultimate installed on my system, and i have problem using the ado.net dbcontext generator, it keeps saying error loading component assembly microsoft,data.entity.design dll please help me out
I am getting the following error message during model build at startup:
"System.Data.Entity.ModelConfiguration.ModelValidationException was unhandled by user code
Message=One or more validation errors were detected during model generation:
System.Data.Edm.EdmAssociationConstraint: : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical.
System.Data.Edm.EdmAssociationConstraint: : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical.
Source=EntityFramework
StackTrace:
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
…."
The error stack does not mention any entity and my project has 400 tables and over 1000 relationships. How can I narrow my search for the offending association?
Hello,
We used "Customizable conventions" on our projects with CTP 5. and we lived 4,1 doesn't have it. Should I wait next release? and when it will be ready?
Thanks in advance.
Hi all,
I have used EF for a while. I am used to using an EDMX file for my model. I have also recently used Code First and the DbContext API and I really like this.
Last night I started building an app. and was thinking, am I starting on the right foot? Do I use EDMX or DbContext API? If the thing im building turns out to be big, Will I have chosen the right technology.
What if I use DbContext API and get it to generate my database. Obviously I dont want this to keep generating my database down the track when im at a stable point in development (or do I?)
The DbContext API is a simplified version. Will it do everything I need? I dont think ill need stored procedures as I can do everything with linq.
So my real question is. If I am building something that is serious and out there is the real word and it may tuen out to require some complex coding, which way do I go? EDMX or DbContext API?
Comments / thoughts?
RuSs
What about Class Diagram designers? is it included in EF 4.1?
visit http://www.entityframeworktutorial.net for basic to expert level learning of entity framework 4.1
We do provide Entity Framework Extension
http://www.zzzprojects.com