使用具有默认标志数据的数据库和表来部署项目的简单方法是什么?(What is an easy way to deploy my project with databases and tables th

编程入门 行业动态 更新时间:2024-10-26 05:31:57
使用具有默认标志数据的数据库和表来部署项目的简单方法是什么?(What is an easy way to deploy my project with databases and tables that have default flag data?)

我有一个使用2个数据库的Windows窗体应用程序,并且有用作标志和引用的表。 默认情况下,使用填充数据的表来部署这些数据库通常会做什么? 我正在考虑使用脚本数据库作为CREATE,然后将所有这些生成的脚本放入一个SQL文件中,让我的应用程序执行它,但是,它只创建数据库或表,而不是所需的数据。

编辑

此外,如果我的应用程序也将具有Windows服务,我是否必须单独设置该设置,还是可以将其包含在我的客户端应用程序设置中?

I have a Windows Form application that uses 2 databases and there are tables that are used as flags and references. What is usually done to deploy these databases with tables filled with data by default? I was thinking of using Script database as CREATE to then put all of those generated scripts into one SQL file and just have my application execute it but, it only creates the database or the tables but not the data needed.

EDIT

Also, if my application also is going to have a Windows Service, do I have to separate the setup for that or can I include that with my client application setup?

最满意答案

默认情况下,使用填充数据的表来部署这些数据库通常会做什么?

正如您已经提到的,其中一个选项是包含脚本以创建数据库模式,然后插入所需的必要数据。 在部署应用程序期间,您可以执行这些脚本。 SMO(SQL Server管理对象)应该是执行脚本的最佳选择。

第二种选择是使用LocalDB ,它是SQL Express的轻量级版本。 您可以将数据库文件添加到安装程序项目,并将其与其他文件一起复制到用户计算机。 当应用程序运行时,您可以使用AttachDbFileName属性在连接字符串中引用此DB文件。

如果我的应用程序也将有一个Windows服务,我是否必须单独设置?

从技术上讲,您可以使用单个设置来部署客户端应用程序并安装Windows服务,但是要安装服务,您必须编写额外的代码。 除非您要求使用单个MSI进行部署,否则我建议您创建一个单独的设置来部署您的服务。

What is usually done to deploy these databases with tables filled with data by default?

As you have already mentioned, One of the option is to include the scripts to create the database schema and then insert the necessary data required. and during the deployment of your application you could execute these scripts. SMO(SQL Server Management Object) should be the best option to execute scripts.

Second option would be to use LocalDB, it's a lightweight version of SQL Express. you could add the database file to your installer project and copy to user machine along with other files. When the application runs you could refer to this DB file in the connection string using AttachDbFileName property.

if my application also is going to have a Windows Service, do I have to separate the setup for that?

Well, technically you could use a single setup to deploy your client application and install windows service but to install the service you will have to write extra code. Unless you have a requirement to use single MSI to deploy both i would advice you to create a separate setup to deploy your service.

更多推荐

本文发布于:2023-08-03 05:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1384118.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标志   简单   数据库   方法   项目

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!