Scott Hanselman

Entity Framework 4.1 Release Candidate with Go-Live (with Final Release to follow in a month)

March 17, 2011 Comment on this post [13] Posted in Channel9 | VS2010
Sponsored By
image

I was in Redmond this last week and talked to Jeff Derstadt, the Lead Developer on Entity Framework Code First (or, as I say, EF Magic Unicorn). What's the deal with this new feature in Entity Framework? What about the bad rap that EF got back in the day? What's new in EF4 and how does EF Code First sit on that? Which is the right choice, Model First, Database First or Code First? All of this plus demos in this off-the-cuff interview. There's lots of good info in this video including some insight into much needed migrations. Hint: They are working on them!

This week, the Entity Framework team put out a Release Candidate of Entity Framework 4.1, and are planning a final release in a month. Hm, what conference happens in a month?

The EF 4.1 RC is now publicly available (“ADO.NET Entity Framework 4.1 Release Candidate” for short, doh!) It's cool that they are able to do out of band releases for things like this, so we don't have to wait a year or more for new functionality.

Note that while CodeFirst is awesome, EF4.1 is not just about Code First, the DbContext API is equally applicable to Database First and Model First and EF 4.1 includes new code generation item templates for customers working with the EDM designer.

What’s in EF 4.1 RC?

From their blog, the ADO.NET Entity Framework 4.1 RC 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.

And an unfortunate but necessary NuGet gotcha, as the package as been renamed.

NuGet Package Rename

Previous releases of Code First were made available as the "EFCodeFirst" NuGet package. The EF 4.1 RC release contains features that are also applicable to Model First and Database First development, therefore we have chosen to adopt the "EntityFramework" package name for this release, and future releases. If you are currently using the "EFCodeFirst" package you will need to swap to the "EntityFramework" package to get the supported go-live release. If you own a package that depends on ‘EFCodeFirst’ we would encourage you to swap the dependency over to the ‘EntityFramework’ package as soon as possible.

Have you implemented the NuGet Action Plan? Get on it, it'll take only 5 minutes: NuGet Action Plan - Upgrade to 1.1, Setup Automatic Updates, Get NuGet Package Explorer.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 17, 2011 3:39
Should the first sentence of the last paragraph actually say:

"Previous releases of Code First were made available as the "EFCodeFirst" NuGet package."



March 17, 2011 4:10
Oops, fixed. Thanks, Will!
March 17, 2011 4:50
Thanks Scott - great info! It's really exciting to see how far this project has come in such a short time. I'm still holding out for a couple of features I just can't live without that Linq to SQL has had since the beginning. If we ever get an equivalent to the .Log property on the DataContext, as well as support for cross database SQL Server queries on the same server, I can finally transition to using EF for real work. Great that 4.1 is out - here's hoping for what I need to actually use it in 4.2!
March 17, 2011 9:27
Hi,

Previously I used Entity Framework 4.0 CTP5 (code-first) and SQL Compact in my projects. I had the following packages installed using NuGet:

1. SQLCE.4.0.8435.1 (version 4.0.8435.1)
2. EFCodeFirst 0.8 (version 4.0.30319.0)
3. EFCodeFirst.SqlServerCompact.0.8 (version 4.0.8435.1)


Now when EF 4.1 RC is published, I want to update all my libraries to the latest version. NuGet feed doesn't contain any updates for SQLCE.4.0.8435.1 anymore, but it has a new package 'SqlServerCompact - 4.0.8482.1' (new package, not a new version of existing package). Presume, that it was just renamed and I should install it. Is it right? Presume, yes.

So what should I install now? Are 'EntityFramework 4.1.10311.0' and 'SqlServerCompact - 4.0.8482.1' enough for using EF code first with SQL Compact? Where is old 'EFCodeFirst.SqlServerCompact' (is it required)?
March 17, 2011 16:05
I have used framwork 4.1 but don,t practising it well . Can you help me for the best method of it
March 18, 2011 20:54
This is very cool and exciting but I still feel like CPT3, though more complex to setup, had much more power being centered around ObjectContext.
March 20, 2011 2:35
I have an MVC3 app which was using EF CTP5. After upgrading to EF 4.1 I get NullReferenceException thrown from here:

at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)

http://stackoverflow.com/questions/5365376/system-nullreferenceexception-after-upgrade-to-ef-4-1

Any ideas?
March 20, 2011 14:37
I can't believe there's still no native Enum support in 4.1. I know there are various bodges to make this work but sadly it's a deal breaker for me :( (between NHibernate and EF). Everything else about EF is excellent.
March 21, 2011 17:16
Yeah enum support is what's holding me back aswell. I'd like to upgrade an NHibernate site but it's not possible without enum support.
March 22, 2011 8:04
Code First and and the abstraction of ObjectContext with DBContext API both look interesting. Thanks for posting.
Tom
March 22, 2011 11:20
They are keenly aware of the need for enum support and are actively working on it...details soon.
March 22, 2011 15:31
Code-First thing in the Entity Framework is great. But.. wouldn't it be cool to have some sort of new enhanced ClassDiagram tool for it? Which would behave more like an Entity Designer tool, able to preserve order of the properties, show metadata (like keys, datatypes), show relationships between objects etc. based on the data annotation attributes attached to POCO classes and their members.

http://data.uservoice.com/forums/72025/suggestions/1547469
March 31, 2011 3:50
I like the T-Shirt, but wouldn't (v2)^2 == (v^2)4

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.