Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate Entities instance. (connection string)
    text
    copied!<p>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;</p> <blockquote> <p>XampParseException was unhandled:</p> <p>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'.</p> </blockquote> <p>And a inner exeption...</p> <blockquote> <p>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.</p> </blockquote> <p>I get to the line public dbEntities() : base(....) but there it crashes. I hope some one could give me a hint what to do. </p> <p>/Nick</p> <pre><code>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(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload