1

I've been using the entity framework in combination with the self tracking entity code generation templates for my latest silverlight to WCF application. It's the first time I've used the entity framework in a real project and my hope was that I would save myself a lot of time and effort by being able to automatically update the whole data access layer of my project when my database schema changed.

Happily I've found that to be the case, updating my database schema by adding a new table, changing column names, adding new columns etc. etc. can be propagated to my business object classes by using the update from database option on the entity framework model.

Where I'm hurting is the CRUD operations within my WCF service in response to actions on my Silverlight client. I use the same self tracking entity framework business objects in my Silverlight app but I find I'm continually having to fight against problems such as foreign key associations not being handled correctly when updating an object or the change tracker getting confused about the state of an object at the Silverlight end and the data access operation within the WCF layer throwing a wobbly.

It's got to a point where I have now spent more time dealing with this quirks than I have on my previous project where I used Linq-to-SQL as the starting point for rolling my own business objects.

Is it just me being hopeless or is the self tracking entities approach something that should be avoided until it's more mature?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
sipsorcery
  • 30,273
  • 24
  • 104
  • 155
  • Have you come to any conclusion regarding this? I'm currently considering switching from LinqToSQL to EF with self tracking entities as well, so I'd really be interested to know. – Adrian Grigore Jun 10 '10 at 09:47
  • I've stuck with the self tracking entities rather than revert to L2S or hand rolled classes. If I had to do the same thing again... I'd probably try and stick with the Entity Framework, I think the modelling approach it uses for the DAL is the way to go and once a good understanding of it is obtained it will translate to increaed productivity. I'm not so sure about self tracking entities. The template code can definitely be improved on and hopefully they'll be updates flowing in the coming months. – sipsorcery Jun 10 '10 at 13:55

2 Answers2

1

What version of self tracking entities are you using?

I'm using the .Net 4.0 version together with visual studio 2010. All CRUD operations work fine, also operation with FK.

I had problems in VS 2008 with FK but that's gone in VS 2010 with .Net 4.0.

If you want, I can provide you some samples.

Greetings

flashbeir
  • 45
  • 5
  • I'm using VS 2010 and .Net 4 as well. CRUD operations mostly work for me as well but the 10% of edge cases take a lot of time to sort out. I wouldn't mind looking over some samples as a sanity check if you've got some readily available. – sipsorcery Jun 06 '10 at 07:59
0

Since STE entity does not support lazy loading you should use Include on the server side include related properties. There is no way to include all related navigation properties. You have to explicitly include the properties. for instance //server side customer.Include("Orders.OrderDetails").Include("Address")

zeeshanhirani
  • 2,330
  • 17
  • 12