Windows Phone 7.1 supports SQL Server CE and LINQ to SQL, as well as upgrading the database via DatabaseSchemaUpdater.
On other platforms I would read the database schema tables (e.g. sys.objects) to view the current schema and work out what tables/columns need to be upgraded.
Given that no direct SQL access is allowed on Windows Phone, how can retrieve the current database schema?
SQL Server CE still includes the
INFORMATION_SCHEMA.TABLESandINFORMATION_SCHEMA.COLUMNStables, but it is a little tricky to access them as no direct SQL access is allowed.However, you can create a
DataContextwhich maps to these tables:You can then read the schema with the following code:
It’s important to create a separate context for these tables, as otherwise the
DataContext.CreateDatabasecall will attempt to create these schema tables, which will fail.