Re-Importing/Updating a SQL Server database projec

2020-05-23 08:41发布

问题:

My team is working with a .NET 2008 DB Project in their solution so we have some way to persist the schema between machines and through development and keep things consistent.

My preferred way of changing the database and keeping track of said schema is through the SQL Server Mangement Studio -- basically, I have a copy of the deployed DB project and make my schema changes to that so there isn't a chance of corrupting my personal development environment. However, when I'd like to move my changes to the codebase, I'm having to add the files manually which I feel might be unnecessarily time consuming (boy am I spoiled!).

My question is -- is there a way I can re-import my altered schema to the DB project without having to remove the project entirely from the solution, and re-adding it by hand?

I feel like I'm missing some really simple step. Help?

回答1:

To update your projects's schema you can use "Schema compare" feature from Data menu. Choose your development database as Source, your database project as Target and get schema comparasion as result. It will find what you have changed since project creating and will show you diffs for tables and other database objects. So you will be able to look through these changes and skip some of them if you like. Then click "Write updates" and your changes are added to the project.