Import Database in VS 2015 SQL Server Database Project

前端 未结 2 518
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 16:41

I recently had troubles Importing a Database from a SQL Server Database Project in VS 2015. Just hoping this helps some folks. I will add more pictures when my rep is higher.

相关标签:
2条回答
  • 2021-02-01 16:57

    Right click on the Project and clicking View in Object Explorer.

    Add and connect to your database next, if needed. Right click on the database you are wanting to import and click Create New Project.

    Change settings if needed. Then Click Start

    0 讨论(0)
  • 2021-02-01 17:01

    Once you open Visual Studio – go to the menu: File -> New -> Project. A new window will be opened and then find the project type: SQL Server Database Project. Having an empty database project you can either create new objects and create a new database from scratch or import existing ones. Please follow the below steps:

    1. Create a new SQL project in the Visual Studio solution
    2. Right-click the new SQL project and choose Import -> Database
    3. Select the database you want to import and click Start
    4. Repeat steps 1-3 above for the History database (IF available)
    5. Add a database reference to the main database that points to the history database a. Database reference to a project in the current solution b. The database location is “different database, same server” c. Replace any periods in the Database variable with underscores. Periods are not supported in the variable name.
    6. Right-click the main SQL project and go to Properties -> SQLCMD Variables a. Add the name of the History database to the Local column of the entry for the History database (something like “Database_History”)
    7. Replace all instances of the History database name with the History database variable a. This occurred at the bottom of the table scripts, where the triggers were generated. b. The correct syntax should look something like this: [$(Database_History)].Schema.TableName
    8. Ensure both SQL projects will build successfully a. There were some cases where I had to explicitly specify the table in which a column appears (ex. ImageID -> REPORTS.Image.ImageID in a stored procedure) b. There were some instances where a stored procedure or a view referred to a column that no longer exists i. Change the Build Action to None c. There were some instances where the project wants to create users for people who are no longer with the company. i. Change the Build Action to None.
    9. Check for differences between the Visual Studio project and the deployed database (if any development happened between you importing the database and finishing the steps above) a. Generate a publish script targeting the deployed database. Anything the script attempts to modify is a difference you should obtain from the deployed database. i. Do not revert any changes made in step 8
    10. Publish the databases to an existing deployed location and ensure functionality remains.
    0 讨论(0)
提交回复
热议问题