Transferring changes from a dev DB to a production DB

后端 未结 5 829
梦谈多话
梦谈多话 2021-01-01 07:13

Say I have a website and a database of that website hosted locally on my computer (for development) and another database hosted (for production)...ie first I do the changes

5条回答
  •  清歌不尽
    2021-01-01 07:49

    The correct way to do this with Visual Studio and SQL Server is to add a Database Project to the web app solution. The database project should have SQL files that can recreate the entire database completely on a new server along with all the necessary tables, procedures users and roles.

    That way, they are included in the source control for all the rest of the code as well.

    There is a Changes sub-folder in the Database Project where I put the SQL files that apply any new alterations or additions to the database for subsequent versions.

    The SQL in the files should be written with proper "if exists" blocks such that it can be run safely multiple times on an already updated database without error.

    As a rule, you should never make your changes directly in the database - instead modify the SQL script in the project and apply it to the database to make sure your source code (the SQL files) is always up to date.

提交回复
热议问题