问题描述
对我的 SQL 数据库结构进行一些更改(使用 SQL Server Management Studio 中的脚本)后,如何在 Visual Studio 中更新我的 DataSet.xsd 文件以匹配新结构?我必须手动执行此操作吗?
我考虑删除 DataSet 并导入一个新的,但我会丢失所有自定义表适配器查询.
After making some changes to my SQL database structure (using scripts in SQL Server Management Studio), how can I update my DataSet.xsd file in Visual Studio to match the new structure? Must I do this manually?
I considered deleting the DataSet and importing a new one, but I'll lose all my custom Table Adapter queries.
推荐答案
来自 MSDN 论坛:
如果您在数据集设计器中右键单击 TableAdapter 并单击配置"TableAdapter 配置向导将打开,您可以在其中重新配置定义表架构的主查询.这应该留下额外的 TableAdapter 查询(额外的方法)在初始配置后添加.
If you right-click the TableAdapter in the Dataset Designer and click 'Configure' the TableAdapter Configuration Wizard opens where you can reconfigure the main query that defines the schema of your table. This should leave the additional TableAdapter queries (the additional methods) that were added after initial configuration.
当然,如果附加方法引用了已从表中删除的列,则它们也需要重新配置数据库,或者如果任何列定义发生更改(例如,如果数据类型已更改或修改).因此,如果一个附加列是添加到表中,它允许 Null 值现有方法应该仍然有效 - 仅取决于架构的更改范围数据库中的表.
Of course the additional methods will also need to be reconfigured if they reference a column that has been removed from the table on the database, or if any of the column definitions change (for example, if the data type is changed or modified). So if an aditional column was added to the table and it allows Null values the existing methods should still work - just depends on the scope of change to the schema of the table in the database.
这篇关于更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!