使用新的架构更改来更新LinqtoSql数据库吗? [英] Update LinqtoSql database with new schema changes?
问题描述
我有一个已发布到市场的Windows Phone 7应用程序.我正在使用带有LinqToSql的Sql CE.该应用程序运行时,会从连接字符串中检查数据库是否存在,并创建数据库是否不存在.
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.
如何更新已经存在的数据库?既然数据库已经存在,我是否必须手动执行ALTER和CREATE表语句来进行调整?
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?
推荐答案
签出Window Phone的本地数据库迁移概述. http://msdn.microsoft.com/zh-我们/图书馆/hh394018(v=VS.92).aspx
Checkout the local database migration overview for Window Phone. http://msdn.microsoft.com/en-us/library/hh394018(v=VS.92).aspx
然后...
http://msdn.microsoft.com/zh-CN/library/microsoft.phone.data.linq.databaseschemaupdater(VS.95).aspx
这篇关于使用新的架构更改来更新LinqtoSql数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!