Type datetime2 is not a defined system type

EF generating wasted db calls

Odd one this! Caused by a fairly innocuous looking

 var result = MyRepository.Select(a => myIds.Contains(a.theirID)).ToList();

It was a two fold effect, datetime2 was being CAST(NULL AS datetime2) AS in the generated SQL therefore at the point where it was being mapped back to entity it was failing a unknown type. The root of the cause was in the blog post. Read it for a nice detailed run at the issue, thanks to the OP :)

This entry was posted in C#, EF4. Bookmark the permalink.

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> <pre lang="" line="" escaped="">