We’ve got an EF model that’s using POCO generation for its types. We added a stored procedure and created a function import for it. We then generated a Complex Type for the result set and let the T4 template generate the business contract (POCO).
Everything works great in our development, devint, and QA environments. When we deploy to production the application works for a while and then starts throwing this exception:
System.InvalidOperationException: The type parameter ‘POCO’ in ExecuteFunction is incompatible with the type ‘EFComplexType’ returned by the function.
If we recycle the application pool the exception goes away for a little while and then comes back, so we recycle the app pool again, and so on…
We have been unable to reproduce the problem in any environment other than production which is making it very hard to determine the root cause.
I doubt anyone has a pat answer to this, but any thoughts as to what it might be, areas we might want to explore, or thoughts on tracking down the root cause would be helpful.
We finally figured out what was causing the problem. We had another service that was also using EF. It was using the ExecuteStoreQuery method that hangs off the ObjectContext. As soon as that method was called all of our other EF queries started to fail with either the above message or an “incompatible metadata” message. We rewrote that query to use standard ADO.NET and haven’t had a problem since.