ADO.NET问题-schlep架构以清空DB文件 [英] ADO.NET question - schlep schema to empty DB file
问题描述
我是ADO.NET数据库编程的新手.
1.我使用VS Designer创建了一个具有表,列,关系和约束的DataSet派生类.大量有用的活动生成的代码,一切都很好.
2.我还使用静态Connection.CreateFile方法创建了一个零字节的DB文件.
我的问题是:如何将模式从DataSet注入到空DB文件中?我也许可以使用大量创建命令来重新创建架构,以创建各个表,关系等,但这真的是将架构从VS Designer创建的数据集迁移到空DataSource的唯一方法吗? >
我最好保留一个空的(无数据)数据库文件实例,然后将其复制到一个新文件中,以便我可以在副本上执行Connection.Open吗?听起来像这样行得通,但似乎有点hack.
I''m a newbie to ADO.NET database programming.
1. I have used the VS Designer to create a DataSet-derived class with tables, columns, relations and constraints. All very nice with tons of generated code for all kinds of useful activity.
2. I also have a zero-byte DB file created with the static Connection.CreateFile method.
My question is this: how does one inject the schema from the DataSet into the empty DB file????? I perhaps could re-create the schema using a boatload of Create commands to create the individual tables, relations, etc, but is that really the ONLY way to migrate the schema from a VS Designer-created DataSet to an empty DataSource?
Would I be better off keeping an empty (data-less) instance of the DB file around and copying it to a new file so that I can do a Connection.Open on the copy? It sounds like that would work, but seems a bit of a hack.
推荐答案
我最常看到的方法是某种安装结构的方法.例如您需要运行的SQL脚本,或从嵌入式脚本运行DDL的程序.
aspnet_regsql.exe 是一个示例.
The approach I see most is some way to install the structure. Such as a SQL Script you need to run, or a program that runs the DDL from an embedded script.
aspnet_regsql.exe is an example.
这篇关于ADO.NET问题-schlep架构以清空DB文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!