如何在 DacPac 中包含数据 [英] How to include data in a DacPac

查看:18
本文介绍了如何在 DacPac 中包含数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 的 Sql Server Data Tools 中,您可以创建一个 Sql Server 项目并导入数据库的结构.这非常有效.

In Sql Server Data Tools for Visual Studio, you can create a Sql Server Project and import the structure of a Database. This works very well.

是否也可以导入数据?例如,假设我有一个包含多种类型的 Type 表.我想在 Sql Server 项目中有这些数据,所以当我发布它时,它也会发布数据.

Is it also possible to import data as well? For example, lets say I have a Type table with several types. I would like to have this data in the Sql Server Project, so when I publish it, it publishes the data as well.

我能想到的最接近的方法是使用 Sql Server 对象资源管理器为数据创建一个脚本,然后手动将该脚本添加到项目中.

The closest I have been able to figure out is to use Sql Server Object Explorer to create a script for the data and then manually add that script to the project.

当我看到Sql Server Data Tools的demo,然后显示发布一个项目,然后使用复制和粘贴来获取数据到数据库中.当然有更好的方法.

When I saw the demo of Sql Server Data Tools, then showed publishing a project, but then using copy and paste to get data into the database. Surely there is a better way.

编辑多年后,我终于弄清楚了:有两种类型的导出:1. DACPAK - 仅包含结构,2. 包含数据和结构的 BACBAK.

EDIT Years later, I finally figure this out: There are two types of exports: 1. DACPAK - which includes only the structure, 2. The BACBAK which includes data and structure.

您可以从 SSMS 创建: 1. DACPAK:选择您的数据库,右键单击任务 -> 提取数据层应用程序.2. 选择数据库,右击Tasks-> Export Data Tier App.

You can created either from SSMS: 1. DACPAK: Select your database, right click for Tasks-> Extract Data Tier App. 2. Select database, right click for Tasks-> Export Data Tier App.

推荐答案

多年后,我终于弄清楚了:有两种类型的导出:

Years later, I finally figure this out: There are two types of exports:

  1. DACPAC - 仅包含结构
  2. 包含数据和结构的 BACPAC.

您可以从 SSMS 创建:

You can create either from SSMS:

  1. DACPAC:选择您的数据库,右键单击任务"->提取数据层应用程序".
  2. BACPAC:选择数据库,右键单击任务 -> 导出数据层应用程序.

这篇关于如何在 DacPac 中包含数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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