Hi,
I have a mapping file generated by SqlMetal, and when I try to instantiate a data context by passing that file, it gives me an exception which says something like "Root level node is invalid, line 1, position 1".
I just put two files, a map file and a datacontext file, generated by SqlMetal into my WCF service project.
Does anyone know why it happens? and how to solve this problem?
-database.map-
<?xml version="1.0" encoding="utf-8"?>
<Database Name="DatabaseName" xmlns="http://schemas.microsoft.com/linqtosql/mapping/2007">
<Table Name="dbo.answer_tbl" Member="Answer_tbl">
...Cointinue
-code-
var rootWebConfig = WebConfigurationManager.OpenWebConfiguration("/WebService");
var connectionString = rootWebConfig.ConnectionStrings.ConnectionStrings["ConnectionString"].ConnectionString;
using(var context = new DatabaseDataContext(connectionString, XmlMappingSource.FromXml("database.map")){
}
thanks in advance, Yoo
Edit
I found a solution at the following link.
http://www.alexthissen.nl/blogs/main/archive/2006/07/09/linq-to-sql-mapping-files-objectspaces.aspx
I just needed to make the mapping file to an embedded resource.