Creation of default data in Visual Studio database

2019-04-09 02:13发布

Are there way to using data generation plans in VS 2010's database projects to create a set of default data? Or am I barking up the wrong tree i.e. are data generation plans best suited to create dummy example data?

We have a bunch of data (default settings, default users etc etc) that needs to be created for each database deployment. It would be nice to have tooling to help us with this, so it can be source controlled and better managed.

I'm guessing that there are probably third party alternatives, but I'm hoping there is a built-in Visual-Studio-Way of doing things, so it can integrate nicely with TFS etc.

1条回答
▲ chillily
2楼-- · 2019-04-09 02:33

There are probably different ways to do this, but the basics are to:

  1. create a script that inserts your default data
  2. Edit the Script.PostDeployment.sql script to use your script for inserting the default values

For example, I created a new folder, DefaultData, under the Scripts->Post-Deployment folder of my project and added my script for inserting the default data here, InsertDefaultData.sql. Then, I added the following line to Script.PostDeployment.sql ":r ..\DefaultData\InsertDefaultData.sql".

查看更多
登录 后发表回答