Search code examples
sql-servergithubversion-controldatabase-migrationdacpac

Version and deployment of SQL Server database


I am planning to move a SQL Server database (with procedure calls and 200+ tables) to version control (github) and deploy using DACPAC. I imported my database into Visual Studio 2017, but I don't have any idea how I will maintain database version and deploy change set


Solution

  • After you imported into VS 2017, you should see the SQL project with all your database objects including tables, stored procedures, functions, views, etc in the folder where you saved in Visual Studio. You can check-in this SQL Project folder with all its contents into GitHub. Use a suitable gitignore file like this https://github.com/gertd/sqlproj/blob/master/.gitignore to avoid cluttering GitHub with non-code files.

    You need to make changes in the Visual Studio for any change in database objects and commit/push to GitHub. If you prefer you can make change in SQL Server directly and then update your Visual Studio project using the schema compare feature, before you push to GitHub.

    To deploy, you can build the SqlProject from Visual Studio which will create/update a dacpac.