Entity Framework 4.1 power tools

The EF team at Microsoft just release a first CTP of the EF 4.1 Power Tools making it even easier to do Code First development with an existing database.

Guess it isn’t really code first in that case but database first Smile

 

I did a quick test with an existing database, Northwind to be exact, and it worked pretty well. The only gotcha is you have to make sure the EF4.1 assemblies are available in your project otherwise you will receive the exception below. Adding Ef4.1 is easy though, just download the installer and install them or even better, just add a package reference using NuGet.

System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at VSLangProj.References.Add(String bstrPath)
   at Microsoft.DbContextPackage.DbContextPackage.ReverseEngineerCodeFirst(Project project)

 

The generated code is a bit more verbose that I would have hand written. For each table a 2 classes are generated, the first is the entity class itself. The second is a map class that defines the mapping between the entity and the database. These contain all the default values that would have just worked, not a problem I guess but it would be nice if default mappings would be omitted keeping the generated files smaller.

Another thing I noticed was that the entities only have their collection properties marked as virtual. The other properties containing the entity data are not virtual.

Read more about the CTP1 here.

 

Enjoy!

 

[f1]
[f2]

One thought on “Entity Framework 4.1 power tools

Leave a Reply

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

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>