Windows Phone更改数据库架构

using (ToDoDataContext db = new ToDoDataContext(("isostore:/ToDo.sdf")))

{

        //Create the database schema updater

        DatabaseSchemaUpdater dbUpdate = db.CreateDatabaseSchemaUpdater();



        //Get database version

        int dbVersion = dbUpdate.DatabaseSchemaVersion;



        //Update database as applicable

        if (dbVersion < 5)

        {   //Copy data from existing database to new database 

            MigrateDatabaseToLatestVersion();

        }

        else if (dbVersion == 5)

        {   //Add column to existing database to match the data context

            dbUpdate.AddColumn<ToDoItem>("TaskURL");

            dbUpdate.DatabaseSchemaVersion = 6;

            dbUpdate.Execute();

        }

}

详细情况请参考:

http://msdn.microsoft.com/zh-cn/library/windows/apps/hh394022(v=vs.105).aspx

你可能感兴趣的:(windows phone)