I have a problem when trying to use Entity framework to connect to my database. I dont really know how to explain so I post some code. I want to make an instance of dbEntities and use it to connect to my DB, in the second section you can see my connection string. I get the following error when I try to run this;
XampParseException was unhandled:
The invocation of the constructor on type 'test.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.
And a inner exeption...
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.":nul.
I get to the line public dbEntities() : base(....) but there it crashes. I hope some one could give me a hint what to do.
/Nick
public class LinqConnection
{
private readonly dbEntities _linq;
private static LinqConnection _instance;
private LinqConnection()
{
_linq = new dbEntities();
}
public static dbEntities Instance
{
get
{
if (_instance == null)
_instance = new LinqConnection();
return _instance._linq;
}
}
}
public dbEntities()
: base("metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SQLite;provider connection string=';data source=db.db3;Password=testpass';", "dbEntities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}