none
Best way to deal with database version differences. RRS feed

  • Question

  • I'm creating a utility used to populate application databases with test data, and I would like it to be flexible enough to run smoothly on several different databases that may be at different versions.

    For the most part, this hasn't been a problem, as most of the tables I'm working with have not changed significantly between database versions.  However, there is one table that is giving me trouble.

    In the older databases this table had an integer field ("SortOrder") that did not allow nulls, and had no default value specified.  In the newer databases this field no longer exists.  My dbml file was generated using a newer database, so it does not include the SortOrder field.  Therefore, when I try to add records to this table on an older database using LinQ to SQL, I'm getting a SqlException due to it trying to insert a record with no value for SortOrder which can't be null.

    My current work-around for this issue is to revert to using raw text SQL queries (rather than LinQ to SQL) to check for the existence of the SortOrder column and insert the records if it does exist, and only use LinQ to SQL if the SortOrder column is not found.

    I'm wondering if there's a better way to deal with this completely through LinQ to SQL.
    Monday, January 4, 2010 3:33 PM

Answers

All replies