Database migration (how to check if table will be created)

1 posts, 0 answers
  1. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 22 Oct Link to this post

    Hello.

    I have added parent table to existing child table with existing data. I want all current data from child table to be deleted during automatic database update.

    Here is the code ( SchemeUpdateInfo.NewTables does not exist, it's just for an example of what I want to do ):

    var schemaUpdateInfo = schema.CreateUpdateInfo(new SchemaUpdateProperties() );
    // Here I want to check if parent table was absent
    //Like this: if( schemeUpdateInfo.NewTables.Contains("ParentTable")){ db.ChildTable.DeleteAllOnSubmit(db.ChildTable);}
    if (schemaUpdateInfo.HasScript)
    {
         schema.ForceUpdateSchema(schemaUpdateInfo);                   
    }
Back to Top