Error creating DataContext

Error creating DataContext

Postby SomeDeveloper » Wed 14 Sep 2011 17:06

I'm getting an error creating a data context instance. This started happening after I changed a column to Nullable = FALSE and updated the database from the model.

Can you please help? If needed I can send the project via email.

Error: InvalidOperationException("You should use the constructor with XmlMappingSource parameter");

Database: SQLite
.NET: 4.0, C#
VS Version: 2010 SP1
Entity Developer Version: 4.0.3
Posts: 1
Joined: Wed 14 Sep 2011 16:54

Postby StanislavK » Thu 15 Sep 2011 14:04

This exception specifies that the 'File' mapping mode is set for the model, and no mapping source was passed to the data context constructor.

To resolve this, you can do either of the following:
1. Set the mapping mode to 'Attributes' and save the model (so that the code is re-generated).
2. If you do use the file mapping (e.g., you have to if you are working with POCO classes), create the XmlMappingSource object from the special .xml file generated by Entity Developer:
Code: Select all
XmlMappingSource mappingSource =
var context = new [YourDataContext](mappingSource);

Please tell us if this helps.
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Return to LinqConnect (LINQ to SQL support)