Start a new topic

Entity Framework & VistaDb

Hello,


I am new to VistaDb and I am trying to get a simple example of talking to a VistaDB database with EF.


I have created a clean Windows Forms App.


Using nugget, I added "Entity Framework" and then "VistaDb 5 Provider for Entity Framework 6 and later"


I then added a new item of "ADO.NET Entity Data Model", created a connection using the VistaDb driver, tested the connection and it worked...


Happy Days!


 I then proceeded to add some code to a button to get a list of visitors from my database as below..

 

Entities db = new Entities();
List<Visitor> visitors = db.Visitors.ToList();

 

But, when I run this code I get the error:


"An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Data.dll"


"Additional information: Failed to find or load the registered .Net Framework Data Provider."


Can anyone tell me what I am doing wrong please?


My app.config looks like this:

 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    <provider invariantName="System.Data.VistaDB5" type="VistaDB.Entity.VistaDBProviderServices, VistaDB.5.Entity.6.NET40" /></providers>
  </entityFramework>
<system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.VistaDB5" />
      <add invariant="System.Data.VistaDB5" name="VistaDB 5 Data Provider" description="VistaDB 5 ADO.NET Provider for .Net 4" type="VistaDB.Provider.VistaDBProviderFactory, VistaDB.5.NET40" />
    </DbProviderFactories>
  </system.data><connectionStrings><add name="Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.VistaDB5;provider connection string='Data Source=&quot;C:\Users\Trevor\Documents\Visual Studio 2013\Projects\InventryDatastoreEF\InventryDB.vdb5&quot;;Password=nottellingyou!'" providerName="System.Data.EntityClient" /></connectionStrings></configuration>

 


1 Comment

Be sure you added a reference to the VistaDB engine (it should have added it) and that it's set to copy local.  Often the second part  is missing.  Rebuild and see if that address it.

Login to post a comment