How to: Validate DBML and External Mapping Files (LINQ to SQL)
External mapping files and .dbml files that you modify must be validated against their respective schema definitions. This topic provides Visual Studio users with the steps to implement the validation process.
Note
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
To validate a .dbml or XML file
On the Visual Studio File menu, point to Open, and then click File.
In the Open File dialog box, click the .dbml or XML mapping file that you want to validate.
The file opens in the XML Editor.
Right-click the window, and then click Properties.
In the Properties window, click the ellipsis for the Schemas property.
The XML Schemas dialog box opens.
Note the appropriate schema definition for your purpose.
DbmlSchema.xsd is the schema definition for validating a .dbml file. For more information, see Code Generation in LINQ to SQL.
LinqToSqlMapping.xsd is the schema definition for validating an external XML mapping file. For more information, see External Mapping Reference (LINQ to SQL).
In the Use column of the desired schema definition row, click to open the drop-down box, and then click Use this schema.
The schema definition file is now associated with your DBML or XML mapping file.
Make sure no other schema definitions are selected.
On the View menu, click Error List.
Determine whether errors, warnings, or messages have been generated. If not, the XML file is valid against the schema definition.
Alternate Method for Supplying Schema Definition
If for some reason the appropriate .xsd file does not appear in the XML Schemas dialog box, you can download the .xsd file from a Help topic. The following steps help you save the downloaded file in the Unicode format required by the Visual Studio XML Editor.
To copy a schema definition file from a Help topic
Locate the Help topic that contains the schema definition as described earlier in this topic.
For .dbml files, see Code Generation in LINQ to SQL.
For external mapping files, see External Mapping Reference (LINQ to SQL).
Click Copy Code to copy the code file to the Clipboard.
Start Notepad to create a new file.
Paste the code from the clipboard into Notepad file.
On the Notepad File menu, click Save As.
In the Encoding box, select Unicode.
Important Note: This selection guarantees that the Unicode-16 byte-order marker (FFFE) is prepended to the text file.
In the File name box, create a file name with an .xsd extension.