Some Tidbits of Entity Framework 4 in Visual Studio 2010 Beta 2

Visual Studio 2010/.NET 4 released today on MSDN for subscribers so we can now start playing.

It is too soon for screenshots but here are some awesome things to look for in Beta 2 after poking around for a bit.

1) Foreign Keys are now the default for new models. You’ll see the foreign key checkbox is ON by default when you reverse engineer a model from the database.

2) Lazy Loading is on by default with new models. In the CSDL’s XML, there is an attribute on the EntityContainer of new models to set lazy loading enabled by default. The default code generator reads this and injects ContextOptions.LazyLoadingEnabled=true into the container class.  You'll need to add this attribute to old models that you bring into Beta2 if you want to have the lazy loading on by default.

3) HIP HIP HOORAY! The function import wizard will read your stored procedures and create complex types from them. Then you can map your stored procs to the complex types. I dream of a batch processor for this one.

4) A new event for ObjectContext: ObjectMaterialized. This will get hit just after the new object's properties and relationships have been populated from the query results. This can be very useful.

Although I’m really looking forward to the Vermont.NET meeting tonight, I’m a little sad that I can’t stay home and keep playing with the bits.

#1 Luciano Moreira on 10.20.2009 at 7:20 AM

Hi Julie.

Does the Beta 2 comes with all the goodies that we have in EF Feature CTP? Or it will continue as an out of band release?

Thanks

Luciano

#2 Alex Konduforov on 10.25.2009 at 2:27 PM

Julie, thank you for the update.

I have the same question as Luciano. I was trying to take a look at Code Only functionality but Microsoft.Data.Entity.Ctp library doesn't exist anymore and I don't know where to find ContextBuilder class (was it renamed and moved somewhere else?). Also, it looks like POCO and Self tracking T4 templates were removed as well. Is it possible to find them somewhere else and add to VS2010 beta 2?

Thank you!

Alex

#3 Julie on 10.25.2009 at 6:03 PM

We're waiting for word from the EF team on when the next Feature CTP will be available. The bit in the Feature CTP (code only, self tracking entities, extra templates) have not been wrapped into Beta2 of VS2010. The original plan was that those things would not get included in the VS2010 RTM anyway but hopefully in a future release they would get folded in. So for now, keep an eye on the team blog for word about an upcoming version of the CTP that will align with Beta 2. It's definitely frustrating becuase you have to choose between moving forward without code only/self tracking entities for now, or sticking with Beta 1. :( I've been copy pasting the T4 for the POCO templates into projects in Beta 2.

#4 Tarique on 10.25.2009 at 6:39 PM

Hi Julie,

So, the change in EF to make Entities self-tracking won't be a part of EFv4/VS2010 RTM ? Also, same thing for code-only ?

I thought they were going to be the major change in the next version of EF.

#5 Tarique on 10.25.2009 at 9:30 PM

Hi Julie,

I have another question about "CodeFirst/POCO clasess/Self tracking Entities". I hope my question makes sense as i'm a bit confused about this.

Basically, right now, the Entities don't do any self tracking. They notify the objectContext when something changes, which in turn updates the ObjectStateEntry.

Now this mechanism won't work for "CodeFirst/POCO clasess/Self tracking Entities". So what will happen to current tracking mechanism when "CodeFirst/POCO clasess/Self tracking Entities" is added to EF ?

Will there be 2 separate tracking mechanisms in EF, one for entities that inherit from EnityObject class and another for POCO classes ?

Or will the current entity tracking mechanism be modified in EF so that it works with both, EntityObject classes and POCO classes ?

#6 Julie on 10.26.2009 at 9:16 AM

@Tarique - as far as the team has said, Code Only & Self Tracking entities will remain in the Feature CTP. But one never knows until the VS2010 RTMs. POCO classes can notify context of changes if the properties are virtual, otherwise the context has to read the pocos to detect changes. THere are a few ways to do that.

#7 Fábio Pandolfo on 1.12.2010 at 9:04 AM

just download de Feature CTP2 and add the reference to visual studio, but note that you need to do this by your hands, looking at this folder -> C:\Program Files\Microsoft ADO.NET Entity Framework Feature CTP2\Binaries\Microsoft.Data.Entity.CTP.dll

the link to download de CTP 2 is here -> www.microsoft.com/.../details.aspx

#8 Fábio Pandolfo on 1.12.2010 at 11:56 AM

to tell the truth... i was wrong... if you install the CTP 2, you just have to reference from the namespace "Microsoft.Data.Entity.Ctp"

the confusion is caused because we think that it will be in "System.Data.Entity.Ctp", but it's not in there, it's in "Microsoft.Data.Entity.Ctp" namespace.

#9 Julie on 1.12.2010 at 7:03 PM

Hi Fabio,

My guess is that it's still Microsoft.Data.etc. because it's not a true part of the framework.

julie

#10 Fábio Pandolfo on 1.26.2010 at 7:50 AM

can't wait for the book!!!

Leave a Comment