Resolve reference warning to object of master database in database projects
If you use some stored procedure or objects that reside into master database, when you compile your database project you will end with warning like this.
|
|
This happens because I used the sp_executesql in my stored procedures, and sp_executesql is one of the stored that resides into Master database. To avoid these warnings you must add a reference to all objects that are in master schema.
This kind of reference is not a simple one, but is a Database reference. You can find a reference of the master db in directory %program files%/Microsoft Visual STudio 9.0/VSTSDB/Extensions/SqlServer/SqlVersion/DBSchemas
The dbschema of master database is really big, almost 8 megabytes, and it can slow down your project compilation, because visual studio needs to analyze it to retrieve definition of all objects of master db. Now, since the original master.dbschema contains definition of thousands of db objects, you can create a shrinked version of it that contains only the definition of those object you really reference into your project.
Reducing the file is really simple, you must create a copy of the original file, then you can delete all elements contained in this newly copied file, the result is a content like this one.
|
|
This is the minimum skeleton of a dbschema file, with all elements node removed, now you begin adding all the elements you need from the original file. As an example since I used the sp_executeSql I goes into the master.dbschema, look for its definition and directly copied into the new reduced file.
|
|
In the end I have a dbschema file with 6 elements, (all those I need) and I can reference it without the risk of slowing down the database project.
Alk.