Update LinqtoSql database with new schema changes?

不打扰是莪最后的温柔 提交于 2019-12-01 21:14:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!