Gibraltar Support

Start a new topic

The Ado... with invariant name 'Sistem.Data.VistaDB5'.....

 situation:
EF 6
VistaDB 5
development in all works.
at the customer I put these dll:

this is the App.config
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<entityFramework>
<providers>
<provider invariantName="System.Data.VistaDB5" type="VistaDB.Entity.VistaDBProviderServices, VistaDB.5.Entity.6.NET40"/>
</providers>
</entityFramework>
</configuration>

This is the DbContext
public class HAMDiplomaDB : DbContext
{

/// <summary>
/// Initializes a new instance of the <see cref="GestionallLightDB"/> class.
/// </summary>
/// <param name="pConnection">The p connection.</param>
public HAMDiplomaDB(string pConnection)
: base(pConnection)
{
mConnection = pConnection;
}
public DbSet<EFQSOARPI> EFLogDiplomaARPI { get; set; }
private string mConnection;
}


This program startup:


SetDefaultConnectionFactory(new SqlCeConnectionFactory("System.Data.VistaDB5"));

so load a table:

using (var db = new HAMDiplomaDB(CnStrHAMDiploma))
{
var rispQso = from iscr in db.EFLogDiplomaARPI orderby iscr.Data descending, iscr.StopOrario descending select iscr;
LogDiplomaARPI = new ObservableCollection<EFQSOARPI>(rispQso);
}

How is it gives me the error when loading the table:

The Ado.Net provider invariant name with 'Sistem.Data.VistaDB' is either not registered in the machine or application config file, or could not be loaded.


the strange thing is that with this config file and attached in the main this line:
SetDefaultConnectionFactory (new SqlCeConnectionFactory ("System.Data.VistaDB5"));
In Visual Studio works.

In the client pc's wrong.
This Link download the program:

http://hb9dni.glasp.ch/download/SetupHAMDiploma.exe

 

rar
(734 Bytes)

That line on its own is innocuous - it sets the default connection factory that is then used to resolve the provider and the database connection string *if you don't explicitly specify the connection string in the model or when creating the context*.   If you look at our samples and even the XML we show in our documentation reflect the default for EF which is the SQL LocalDb connection factory.


Reading the source code for the SqlCeConnectionFactory if you pass it a string without an = in it, it assumes it's the file name of the database to open and it then tries to create the SqlCe provider.  I'd expect that provider *does* exist on your development system (installed with Visual Studio) but would not generally be available on a client, causing a failure at runtime there.


You can avoid the connection factory by having a connection string name configured in your DbContext or specifying the name/connection string when you create the DbContext each time.  Meanwhile, we're working to create a version of the connection factory for VistaDB.

I do not know how to solve.
Maybe change DB and I go on SQLCE.
Sorry for my English.
Enclosed is the source that works.

 

rar
(5.59 MB)
This source works on the client ...
I just set the property "Copy Local" file "VistaDB.5.NET40" True (in Visual Studio)... accidentally was False.
He had to work too ...
Bo.

 

rar

So the issue is resolved?  Indeed, setting that copy local option is a critical step to ensure you're distributing the VistaDB engine.

Hello Stefano,


It sounds like the System.Data.VistaDB assembly isn't getting distributed with your application. When you deploy your application, are you adding VistaDB to the GAC or local with your executable? I would double check to make sure the assembly is located where it should be.


I hope that helps.

I see two other issues:

1. You need to include the VistaDB5 ADO.NET provider itself in the configuration file, not just the EF provider.

2. I'm not sure you're going to get success with the "SqlCeConnectionFactory"


I'd recommend carefully reading through our deployment guidance:
http://www.gibraltarsoftware.com/Support/VistaDB/Documentation/WebFrame.html#DevelopersReference_Deployment.html

in the application folder there are these dll:
VistaDB.5.Entity.6.NET40
VistaDB.5.NET40
no in GAC

Now I try to put them in GAC

 

attached the fill app.config,
without the part
SetDefaultConnectionFactory(new SqlCeConnectionFactory("System.Data.VistaDB5"));
generates the error attached

 

rar

We highly recommend against putting the assemblies in the GAC;


The configuration file you sent in the zip file looks right.


We don't provide a VistaDB implementation of the EF 6 IDbConnectionFactory - which is an oversight. I'll talk to the team and have them make that.  Looking at our samples and our own usage, we've tended towards passing in a complete connection string to the DbContext overload that takes a connection string.  I think by using the SqlCeConnectionFactory you're pushing it to use the SqlCe ADO.NET provider, not sure - we can't see from the error message what provider it's actually looking for.

You've sent us down a good road - Digging into this just a little we can easily create a VistaDBConnectionFactory and publish it out to NuGet.  That should remove the need to explicitly register the VistaDB provider with EF as well.  That said, looking at the source code of Microsoft's implementation of SqlCeConnectionFactory it does hardcode their ADO.NET provider which explains the error your getting (in other words, that's just not going to work). 

Yes. Now it works.
but I always use the part SQLCE.
Thank you very much.

 

Login to post a comment