强类型数据集和架构更改 [英] Strongly typed datasets and schema changes

查看:148
本文介绍了强类型数据集和架构更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用强类型数据集的项目。

让我们假设我想改变该应用程序使用的数据库的数据库架构。 我有一个名为Country表,我想添加一个名为IsADemocracy新柱(即是一个例子)的SQL Server数据类型BIT的。

现在,我该如何更新强类型数据集,这样我可以在应用程序中使用这一新的领域?

我试着将数据集中的地区表列,给了它的布尔类型和对应的来源属性设置为IsADemocracy。

我可以访问领域的应用,给它一个价值等,而是由表适配器做基础查询没有被更新,以反映这种变化。他们是因为他们之前,我的强类型数据集加入此列。 我希望我做的事就足够了,但它似乎并不如此。

我应该重新产生强烈的DataSet类不知何故?如果是这样,如何​​和什么影响?

我大概可以删除Country表中的DataSet设计器,并从服务器资源管理器redrop它,但我有客户查询就可以了,我不希望失去他们。

感谢。

解决方案
  1. 首先,确保你有一个备份

  2. 右键单击在解决方案资源管理器和的.xsd节点上​​选择运行自定义工具

但要小心你的自定义查询。他们有一种倾向,而不警告消失。并非总是如此。

这是一个很好的理由来填充这些查询组成部分类'主'的文件。

I have a project which uses strongly typed datasets.

Let's assume I want to change the database schema of the database used by this application. I have a table named Country and I want to add a new column named "IsADemocracy" (that's an example) of the SQL Server datatype BIT.

Now, how do I update the strongly typed dataset so that I can use this new field in the application?

I've tried adding the column in the Country table on the dataset, gave it the type of boolean and mapped its "Source" property to "IsADemocracy".

I can access the field in the application, give it a value, etc, but the underlying queries made by the table adapter have not been updated to reflect this change. They are as they were before I added this column in the strongly typed dataset. I hoped what I did would be enough but it does not seem to be the case.

Should I regenerate the strongly datasets classes somehow? If so, how and what are the implications?

I could probably delete the Country table in the Dataset designer, and redrop it from the Server Explorer, but I have customer queries on it and I don't want to lose them.

Thanks.

解决方案

  1. First, make sure you have a backup

  2. Right click on the .xsd node in Solution Explorer and select "Run Custom tool"

But be careful with your Custom Queries. They have a tendency to disappear without warning. Not always.

This is one good reason to fill in those queries form the partial class 'main' file.

这篇关于强类型数据集和架构更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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