News

Troubleshooting Entity Framework Connection Strings

Author: Craig Stuntz In an application which uses the Entity Framework, you may see the following error at runtime: MetadataException: Unable to load the specified metadata resource The cause of this error is a missing or malformed Entity Framework connection string. In particular, the cause of this error is the metadata parameter of the connection string. Let’s examine this more…
Read more
News

In LINQ, Don't Use Count() When You Mean Any()

Author: Craig Stuntz If you have a list, array, or query in a C#/LINQ application and need to check and see if the list is empty, the correct way to do this is to use the Any() extension method: if (q.Any()) { Similarly, you can check to see if any elements in the list…
News

Entity Framework Models and Source Control

Author: Craig Stuntz As you’re probably aware, an Entity Framework model is stored in a single XML file, with the extension EDMX. Developers occasionally ask if this means that two people cannot work on the entity model concurrently. My answer to this is, “It…
News

join in LINQ to SQL and LINQ to Entities Considered Messy, Redundant

Author: Alf Christophersen In this post I will demonstrate that use of the join keyword in LINQ to SQL and LINQ to Entities is nearly always wrong. LINQ queries which you write with the join keyword are harder to read and write than queries you write using associations, and they require knowledge of database metadata which is not required otherwise. This introduces the potential for errors and…
Read more
News

In LINQ, Beware of Skip(0)

Author: Marc Geldon Calling IQueryable<T>.Skip(0) seems like it should be “free.” In other words, since it will have no effect on the resulting data, there should be little to no performance cost for calling it. But this is demonstrably not true in LINQ to…