Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creation of default data in Visual Studio database projects / SQL Server

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.

like image 655
Alex KeySmith Avatar asked May 10 '11 16:05

Alex KeySmith


1 Answers

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".

like image 64
Flahrty Avatar answered Sep 30 '22 14:09

Flahrty