2

I notice that even slight variances between the database and the entity model will cause queries to fail. For example, say a column is added to a table that I am querying, even if that column is inconsequential to the query it will fail. Is there any way to get Linq to Entities to handle minor database variances more gracefully? That is, ignoring any variance that does not affect the query?

Some context here, I'm using Linq to Entities to work a with a database for a legacy product of ours. We make changes to our database frequently (mostly column or table additions), for better or worse, and I'd like to be able to handle some of these changes without requiring our customers to be completely updated.

Hope that make sense. My thanks in advance!

Perishable Dave
  • 2,858
  • 2
  • 24
  • 29
  • Clarify "inconsequential" and the types of changes you are making. For example, do your added columns allow nulls? – Anthony Pegram Feb 27 '12 at 21:14
  • Good question, lets say it allows nulls or has a default value. – Perishable Dave Feb 27 '12 at 21:17
  • 4
    And you aren't doing *silly* things like eliminating columns or changing names or types? Generally, I have found EF to be robust in the face of change as long as the *things presently known by EF* have not changed, and sensible defaults/nulls are in place for new columns. (But this is based upon observations of changes for internal use, so variances are always extremely temporary.) – Anthony Pegram Feb 27 '12 at 21:27
  • If you *add* a column it shouldn't fail. If you remove or rename one, change type/nullability then you can run into errors. – KristoferA Feb 28 '12 at 05:40
  • 1
    The question is missing real details. Show the problem which caused your query to fail with all relevant details otherwise your question cannot be answered. – Ladislav Mrnka Feb 28 '12 at 09:43
  • Based on the comments it looks like I could be wrong about how the Entity Framework handles added columns, especially added columns with defaults or null columns. Can anyone provide definitive references to how the Entity Framework handles these cases? I'll gladly accept that answer. – Perishable Dave Mar 02 '12 at 20:53
  • It's definitely "For Worst". Use your leadership skills and start working on convincing them of that. – Honorable Chow Sep 12 '13 at 17:30

0 Answers0