Looking at EF4 CTP5 in Parts: Part 1 – A New T4 Template

The Entity Framework 4 CTP5 was just released. There are lots of new features that affect the core use of Entity Framework as well as Code First.

I’ll run through some of these features one blog post at a time. The first is the new T4 Template that gets installed, the ADO.NET DbContext Generator.

 T4Template

This creates a more lightweight context that inherits from DbContext. DbContext was introduced in CTP4 and exposes a simpler way of working with most commonly used features of ObjectContext.

generatedcontext

 

The POCO classes that are generated are much simpler also. Here’s one of the classes. Notice that, unlike the POCO templates we’ve had for a while, these don’t bother with adding in extra logic for two way navigation (the FixupCollection) for the navigation properties.

simpleclasses

Since we don’t need the FixupCollection, the additional file that the POCO template created to define the FixupCollection is still there but it is now empty.

nosupportingcodenecessary

Leave a Reply

Your email address will not be published. Required fields are marked *


3 + = twelve

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>