If you’re using MS SQL Server, Visual Studio’s database projects are a good way to manage your database objects. After importing your database schema, if you working with existing databases, or creating from scratch, you will typically need a reference to the master.dbschema. A typical error due to an unresolved server login reference will say “Error TSD03006: User: [someuser] has an unresolved reference to Login [someuser].”.
The schema file is just a xml file of the server object meta data, this is how it can resolve references when referenced by other database projects in your solution. The VS Database Project comes with master.dbschema files that you can copy and modified if needed. The different version of SQL server schema files can be found in “C:\Program Files\Microsoft Visual Studio 9.0\VSTSDB\Extensions\SqlServer\”, if “C:\Program Files\” is your installed path of VS. I would copy the master.dbschema file that you need to another location and rename with an appropriate name so others know what it represents. If you have server logins that you don’t want to manage through you build and deploy, adding them to this copied master schema file is the way to resolve the build references. Below shows the an example of the element that would need to be added to the dbschema file to resolve a particular login, the added part is italicized and bold.
<DataSchemaModel FileFormatVersion="1.0" SchemaVersion="1.0" DspName="Microsoft.Data.Schema.Sql.SqlDsp.Sql100DatabaseSchemaProvider" CollationLcid="1033" CollationCaseSensitive="False">
<Header>
<CustomData Category="ModelCapability">
<Metadata Name="ModelCapability" Value="Default" />
</CustomData>
<CustomData Category="DBSchema">
<Metadata Name="DatabaseType" Value="master" />
<Metadata Name="SqlServerVersion" Value="10.00" />
<Metadata Name="Author" Value="Microsoft Corp." />
</CustomData>
<CustomData Category="DatabaseVariableLiteralValue">
<Metadata Name="Name" Value="master" />
</CustomData>
</Header>
<Model>
<Element Type="ISql90Login" Name="[someuser]">
<Property Name="DefaultLanguage" Value="us_english" />
<Property Name="IsCheckPolicyOn" Value="False" />
<Annotation Type="GloballyScoped" />
</Element>
</Model>
</DataSchemaModel>
1 comment:
Thanks for a great read
Post a Comment