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

ⅰ亾dé卋堺 提交于 2019-12-21 17:16:33

问题


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:


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



来源:https://stackoverflow.com/questions/5953180/creation-of-default-data-in-visual-studio-database-projects-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!