Schema Versioning

The DatabaseSchemaUpdater class provides a DatabaseSchemaVersion property that allows you to programmatically distinguish between different versions of your database.

When a local database is created with the DataContext.CreateDatabase method, a table named _Version is automatically created. This table holds the current DatabaseSchemaVersion number.

In the following example, the database version is used to determine what needs to be done to update the schema to the current version:

using (TwitterDataContext dataContext                 = twitterDatabaseUtility.CreateContext()){    DatabaseSchemaUpdater updater                 = dataContext.CreateDatabaseSchemaUpdater();    int databaseVersion = updater.DatabaseSchemaVersion; ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.