# How to: Validate DBML and External Mapping Files

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 Personalizing the IDE.

### To validate a .dbml or XML file

1. On the Visual Studio File menu, point to Open, and then click File.

2. 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.

3. Right-click the window, and then click Properties.

4. In the Properties window, click the ellipsis for the Schemas property.

The XML Schemas dialog box opens.

5. 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.

6. 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.

7. 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

1. Locate the Help topic that contains the schema definition as described earlier in this topic.

2. Click Copy Code to copy the code file to the Clipboard.

3. Start Notepad to create a new file.

4. Paste the code from the clipboard into Notepad file.

This selection guarantees that the Unicode-16 byte-order marker (FFFE) is prepended to the text file.