Tigraine
Daniel Hoelbling talks about .NET

Linq to Sql Association weirdness

February 24th, 2009 . by Daniel Hölbling

When your dbml designer shows an association, you’d expect to be able to traverse it in code don’t you?

image

So, funny thing. The Post entity lacks a “PostTags” Field that should be there according to the designer.

After a few minutes of tinkering, I realized that PostTag has no primary key of it’s own. Since in my real application it’s a m:n association table and no entity on it’s own I didn’t use a primary key. But apparently Linq to Sql needs a primary key to work with, so once I changed the table to have a PK magically a PostTags field appeared:

image

Once again I get how “version 1” Linq to Sql really is, but sadly there won’t be a version 2 since Microsoft is now pushing all resources towards the Entity Framework.

Why not EF? Too complex, once I reach a level of complexity that would justify the use of EF, I use NHibernate.
What I need out of Microsoft right now, is some Linq enabled ORM that’s dead simple with a very DB-centric view that works. Something like Linq to Sql v2.


blog comments powered by Disqus