Using an Xml Mapping File
When you choose to use Xml mappings by setting the output setting MappingsAsExternalXmlFile to true, the xml file with the mappings is added to the VS.NET project as EmbeddedResource.
This means that you have to obtain the mappings from the assembly using a streamreader on the resource. The following code illustrates this. Project name is Northwind and the root namespace specified when generating code is Examples.
var modelAssembly = typeof(NorthwindDataContext).Assembly;
var resourceStream =
modelAssembly.GetManifestResourceStream("Examples.NorthwindMappings.xml");
var ctx = new NorthwindDataContext(XmlMappingSource.FromStream(resourceStream));
Dim modelAssembly = GetType(NorthwindDataContext).Assembly
Dim resourceStream = _
modelAssembly.GetManifestResourceStream("Examples.NorthwindMappings.xml")
Dim ctx As New NorthwindDataContext(XmlMappingSource.FromStream(resourceStream))