When using a SQL Server Database Project in Visual Studio, if you have more than 1000 stored procedures in a database, when you import it Visual Studio will split the procedures into separate directories.
When you attempt to sync any new stored procedures into the project following such an import, via the 'Schema Compare' function, Visual Studio forgets this split folder structure and places all new scripts directly into the 'Stored Procedures' folder. This means that new stored procedures which are scripted do not fit into the existing structure, which forces the user to either live with this detached structure or to manually update project references and copy the files back into the initial structure which Visual Studio created.
Steps
- Create a new SQL project.
- Right click on the project in solution explorer > select 'Import' > 'Database'.
- Bind the project to a SQL2008 database which has more than 1000 stored procedures. Select 1000 for 'Maximum files per folder'.
- Allow VS to script out all of the stored procedures. It will automatically break into batches of 1000 and create a new folder 'Proc1', 'Proc2' for each batch as necessary.
- Open a new comparison by right clicking on the SQL project > select 'Schema Compare'.
- Verify the database synced correctly by comparing the SQL project to your original database. There should be no pending changes.
- Create a new stored procedure in the database which was synced.
- Run the comparison again, this should now show the new stored procedure under the 'Add' type.
- Click 'Update' and allow VS to create a script for the new procedure.
- Instead of placing the new script in the original 1000 delimited folder structure, it will instead place the new script in the 'Stored Procedures' folder directly.