Entity Framework 4.0

Entity Framework 4.0

Old forum URL: forums.lhotka.net/forums/t/8759.aspx


rfcdejong posted on Saturday, April 03, 2010

Has someone already dived into using EF 4.0?

EF4 has POCO (Code Only) support which could be good in combination with Csla. I wonder if it would be possible to let an ContextBuilder wrap an CSLA BO and use an EntityConfiguration for mapping the CSLA BO to one or more db tables.

How do u guys see "EF4 fit into CSLA" or  "CSLA works with EF4" ?

RockfordLhotka replied on Monday, April 05, 2010

Sergey looked into having EF4 work directly with CSLA - as in having the EF designer create CSLA objects. It looks technically possible, but extremely difficult. The way this is done is to create custom T4 templates, which is no small task. And of course that means maintaining them as T4 evolves over time and EF evolves over time. The more I learn about that approach the more I realize that integrating with EF at that level would probably become the only thing CSLA would do...

At the moment then, I look at EF4 the way I did EF2 - it is something you invoke in your DAL to get the data necessary to populate your objecs.

But if your objects are relatively data-centric you could probably do as you suggest and use the POCO as a private field of the object. This wouldn't work going to Silverlight (because they wouldn't inherit from MobileObject or use managed properties), but it would work on .NET. Though even on .NET you should know that there would almost certainly be complications because of the references maintained between the POCO objects themselves. At a very least they would bloat the size of your serialized data stream.

Jav replied on Tuesday, April 06, 2010

RockfordLhotka

The more I learn about that approach the more I realize that integrating with EF at that level would probably become the only thing CSLA would do...

Pardom me!  I'm Sorry.   I didn't understand what you said.Huh?

Jav

RockfordLhotka replied on Tuesday, April 06, 2010

Jav

[quote user="RockfordLhotka"]

The more I learn about that approach the more I realize that integrating with EF at that level would probably become the only thing CSLA would do...

Pardom me!  I'm Sorry.   I didn't understand what you said.Huh?

Jav

What I meant is that building and maintaining the T4 templates appears to be so complex and time consuming that I would be unable to do other things, like make CSLA work with Silverlight, the Windows Phone, etc.

And to me, building T4 templates sounds like the worst and least fun thing I can imagine - or close. But working with Silverlight and the Windows Phone is pure joy. So you can probably imagine where my priorities will be Smile

fretje replied on Wednesday, April 07, 2010

Check this.

Copyright (c) Marimer LLC