问题
I have a Windows Phone 7 application that has been published to the marketplace. I'm using Sql CE with LinqToSql. When the app runs, it checks for the existence of a database from a connection string, and creates if it doesn't exist.
using (CheckbookDataContext db = new CheckbookDataContext(DBConnectionString))
{
if (!db.DatabaseExists())
{
isNewLoad = true;
db.CreateDatabase();
}
}
As I begin to plan new features, I foresee some changes to the database schema, whether it be adding a new column to an existing table, adding new tables, etc.
How does one go about updating the already existing database? Do I have to manually execute ALTER and CREATE table statements for my adjustments now that the database already exists?
回答1:
Checkout the local database migration overview for Window Phone. http://msdn.microsoft.com/en-us/library/hh394018(v=VS.92).aspx
And...
http://msdn.microsoft.com/en-us/library/microsoft.phone.data.linq.databaseschemaupdater(VS.95).aspx
来源:https://stackoverflow.com/questions/8570959/update-linqtosql-database-with-new-schema-changes