是否可以从dbml文件更新旧数据库? [英] Is it possible to update old database from dbml file ?

查看:106
本文介绍了是否可以从dbml文件更新旧数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我最近开始了一项新工作,一个非常有趣的项目(C#、. Net 4,Linq,VS 2010和SQL Server).立刻,我面临了一个非常激动人心的挑战:我必须实现一个新工具,或者在程序启动时或任何时候集成逻辑,但是必须发生的事情如下:客户拥有以前的应用程序和数据库(包含他们的特定数据).现在已经准备好新版本,客户可以获取更新.同时,我们对数据库进行了一些修改(新表,列,也许删除了旧列或其他内容).我在Linq和SQL数据库中还是一个新手,我的第一个解决方案可以是:检查应用程序/数据库版本并逐步比较所有表,列,键,约束等,以实现所有更改(所有这些新信息)我在dbml中有,而我在现有数据库中要求的是旧的.每当版本更改时,我都会这样做.但是以某种方式,我觉得这不是一个明智的解决方案,因此我正在寻找此问题的一般解决方案.
有没有一种方法可以从dbml文件中更新客户数据库?创建一个新的不是问题(带有DataContext的CreateDatabase),是否有任何更新/更改数据库方法?我想我不是唯一寻求这种解决方案的人(我在互联网上一无所获-或寻找了错误的关键字).您是如何解决这个问题的?我还寻找外部工具,但首先要寻找使用C#,Linq或类似工具的解决方案.
如有任何想法,请提前谢谢!
最好的问候,
Emil

Hi all,
I began recently a new job, a very interesting project (C#,.Net 4, Linq, VS 2010 and SQL Server). And immediately I got a very exciting challenge: I must implement either a new tool or integrate the logic when program start, or whatever, but what must happen is the following: the customers have previous application and database (full with their specific data). Now a new version is ready and the customer gets the update. In the mean time we made some modification on DB (new table, columns, maybe an old column deleted, or whatever). I’m pretty new in Linq and also SQL databases and my first solution can be: I check the applications/databases version and implement all the changes step by step comparing all tables, columns, keys, constrains, etc. (all this new information I have in my dbml and the old I asked from the existing DB). And I’ll do this each time the version changed. But somehow I feel, this is NOT a smart solution so I look for a general solution of this problem.
Is there a way to update customers DB from the dbml file? To create a new one is not a problem (CreateDatabase with DataContext), is there any update/alter database methods? I guess I’m not the only one who search for such a solution (I found nothing in internet – or I looked for bad keywords). How did you solve this problem? I look also for an external tool, but first for a solution with C#, Linq or something similar.
For any idea thank you in advance!
Best regards,
Emil

推荐答案

MSDN [ ^ ]

版本2:

对于更新:
MSDN [
MSDN[^]

rev 2:

For the update:
MSDN[^]


我没有适合您的方案的解决方案,但是据我了解的DBML文件,它们的目的是创建类,而不是数据库.另一方面,它们只是XML,因此经过两三个月的工作,应该可以将它们用于此目的. :)

严重的是,对我来说,这听起来像是一个死胡同.数据库模式更新有很多标准方法.您可以通过谷歌搜索它,或者,我相信比我更专业的人将能够为您提供帮助.
I do not have a solution for your scenario but from what I understand of DBML files, their purpose is to create classes, not databases. On the other hand they are only XML, so with two or three months work it should be possible to use them for that. :)

Seriously, though, it sounds like a dead end to me. There are loads and loads of standard methods for database schema updates. You could google for it, or, I am sure that someone with greater expertise than I will be able to help you.


这篇关于是否可以从dbml文件更新旧数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆