I have this code:
using DC = MV6DataContext;
using MV6; // Business Logic Layer
// ...
public DC.MV6DataContext dc = new DC.MV6DataContext(ConnectionString)
I had a slightly different situation than the asker, but got the same error for the same reasons. I wrote new constructors in a partial class for my database entities, then tried to use the resulting objects in InsertOnSubmit calls.
None of these answers helped me directly, but I was able to figure out what they were getting at after reading all of them.
The auto-generated parameterless constructor for the entity does things that need to happen for InsertOnSubmit to work, so if you overload the constructor -- like me -- or inherit from the class -- like the asker -- you need to call the base constructor from your new constructor, like so:
public partial class Entity {
public Entity( Type parameter ) : this() {
// do things with the parameter
}
}
or
public class SubEntity: Entity {
public SubEntity( Type parameter ) : base() {
// do things with the parameter
}
}