I've developed a windows application in C#.net and entity framework and database is oracle. I've successfully deployed this application on server machine and application works fine.
When this application is access on client machine then the connection to db is working but when trying to open the form it throws exception-
"The specified store provider cannot be found in the configuration, or is not valid".
I am using oracle XE and entity frame work 6.0
Can anyone please help me to solve this issue.
Your project does not seem to know about the provider you are trying to create. You need to add it to your project's app.config file.
For example, here's one for MySQL:
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
</DbProviderFactories>
</system.data>
Just change the details to suit the Oracle provider you are using. I'm not familiar enough to give a more specific example.
Related
I thought that sqlite was simple but it is giving me a hard time. I just want to create an application where I can connect to a sqlite database using the ado.net entity data classes.
I am having this problem when testing the application on a virtual computer running windows xp. the application works fine on my current computer and also on my laptop when I deploy them.
Here is what happens on the virtual computer :
The application is able to launch.
The application is able to interact with the database using System.Data.SQLite
The application is not able to connect to the database using The ADO.NET Entity data models
when I try to connect I get the following exception:
I know there are a lot of post that talk about this and most of them say that you need to download the .NET provider for Sqlite.
I have already installed the sqlite-netFx40-setup-bundle-x86-2010-1.0.79.0.exe and I get the same problem. What should I do?
Edit
I managed to establish a connection by adding:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
to my app.config file.
The problem is that now I cannot select data nor insert records to the database. The exception that I get when I try to insert a new record now is:
A null was returned after calling the 'GetService' method on a store provider instance of type 'System.Data.SQLite.SQLiteFactory'. The store provider might not be functioning correctly.
had to add:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
to my app config file. and it now looks like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
In the location where sqlite was installed I had to copy
to my output directory where my program exe is located
Install SQLite Toolbox through extensions
Download the latest setup file sqlite-netFx46-setup-bundle-x86-2015-1.0.xxx.0.exe
Install the correct x86 installation, installing VS designer components is a option in the MSI, there is bold text detailing this underneath the correct installation.
Restart and check SQLite in GAC was installed correctly by clicking the blue question mark above your connected databases underneath SQLite toolbox.
At this point you should see "SQLite EF6 DbProvider in GAC - Yes."
Elsewise, you most likely configured your machine.config manually in the past. Delete the changes you made underneath system.data > DbProviderFactories.
Restart VS and you should see "SQLite EF6 DbProvider in GAC - Yes."
Install System.Data.SQLite under the NuGet manager.
You can now connect to SQLite as a binding source and directly select your database file through "SQLite Database" vs "SQLite Provider (Simple for EF6 by ErikEJ)."
refer to this link, this solution was taken from a detailed github post, step by step
I'm trying to to work with Entity Framework 6, and connect it to a Postgresql
database.
I'm using npgsql.Entityframework, but get an error when creating the ddex file.
Can someone knows why?
Thanks.
Install Npgsql, to work between Entity Framework to PostgreSql:
Download and install the Setup_NpgsqlDdexProvider.exe from https://github.com/npgsql/npgsql/releases.
Open Visual-Studio, click on the tab: TOOLS -> Setup Npgsql DbProviderFactories.
A window will open, you need to click OK.
Close Visual-Studio and open as administrator the two machine.config files of .NET with notepad.
There are two file that we need to edit, you can find the file at the paths:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
Add the flowing element to the files:
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql"/>
<add name="Npgsql Data Provider"
invariant="Npgsql"
description=".Net Data Provider for PostgreSQL"
type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
support="FF" />
</DbProviderFactories>
</system.data>
Reopen Visual-Studio at the wanted project.
Install Entity Framework through Nuget.
Open the Package Manager Console and insert the commend:
Install-Package EntityFramework6.Npgsql
Check that the wanted DLL are references, like so:
If not add the DLL manually. The sopose to be at the paths:
C:\Users\YOURCOMPUTERNAME\documents\visual studio 2015\Projects\PostgreSqlVsEfwDemo\packages\Npgsql.3.0.5\lib\net45\Npgsql.dll
C:\Users\ YOURCOMPUTERNAME\documents\visual studio 2015\Projects\PostgreSqlVsEfwDemo\packages\EntityFramework6.Npgsql.3.0.5\lib\net45\EntityFramework6.Npgsql.dll
Open the App.config\Web.config and add two elements:
The provider element at entityFramework -> providers. as so:
The provider element at DbProviderFactories. as so:
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
</DbProviderFactories>
If the <system.data> element isn't exist, add it all.
Now lets add Entity Data Model like so:
Select "EF Designer from database"
Click on "New Connection"
Choose the "PostgreSQL Database" as the Data source:
Filled the fields:
HOST
USERNAME
PASSWORD
PORT
DATABASE (fill this field last.)
Click on "Test Connection" to see if it works.
Continue with Entity Framework as regular.
Hope it's help you.
This document of Npgsql Docs really helped me, but still have problems.
Im using Visual Studio 2010 Ultimate, C# WPF, MVVM, Sqlite.
I have this project that is running without problems (On Windows 8 x64, .NET Framework 4 Client Proile), but I get all this exceptions when run an installed application (On Windows 7 x32, .NET Framework 4 Client Proile):
Exception: System.Windows.Markup.XamlParseException: 'The invocation of the constructor of type' GestorDocument.UI.DeterminanteView 'that matches the specified binding constraints threw an exception.' (Line number: '3 ', line position '9'). ---> System.ArgumentException: The specified store provider can not be found in the configuration or is not valid. ---> System.ArgumentException: Could not find the data provider. NET Framework requested. It may not be installed.
This is my connection string:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="GestorDocumentEntities" connectionString="metadata=res://*/GestorDocument.csdl|res://*/GestorDocument.ssdl|res://*/GestorDocument.msl;provider=System.Data.SQLite;provider connection string="data source=C:\SQLITE\BD\GestorDocument.s3db"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>
Please, Any idea?
Now it works!
MY SOLUTION WAS:
App.config in your project:
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.85.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</DbProviderFactories>
</system.data>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
Include a reference of: (version for the machine on which the application will be installed.)
SQLite.Designer.dll
System.Data.SQLite.dll
System.Data.SQLite.Linq.dll
Set "Copy local" property to True.
Add in machine.config this line between system.data and DbProviderFactories
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.85.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
Ensure that the version of. NET Framework, which was developed the application, is installed on the test machine.
The System.Data.SQLite provider isn't installed on the machine. The correct installation not only drops the binaries on the machine (probably the GAC), but also drops an entry into machine.config that looks something like this (this is NOT REAL):
<system.data>
<DbProviderFactories>
<add name="System.Data.SQLite"
invariant="System.Data.SQLite"
description="SQLite Framework Data Provider for SQLite databases lol"
type="SomeProviderFactory, System.Data.SQLite, Etcetera=etcetera"/>
<!--snip-->
</DbProviderFactories>
</system.data>
Configuration settings (like this database provider configuration) in machine.config are inherited by your application's derp.exe.config file. In your .config file, you are configuring EF to use the SQLite provider (from the middle of your EF connection string):
provider=System.Data.SQLite;
If you look up at the hypothetical entry, it has a provider name that's the same as in your connection string. That's how EF knows to use the SQLite factory to create a connection to the database. See, it's not really magic at all. Its just hidden.
So what's the solution? Hell if I know. I mean, I use a REAL compact database, not this SQLite stuff. You will either have to install SQLite on the target machine, add the factory definition to your .config file, or do something else, like construct a plane out of bamboo.
I am using SQLite in my Winforms application. I am copying System.Data.SQLite.dll and System.Data.SQLite.Linq.dll in output directory.
App.config
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
The application is throwing "Failed to find or load the registered .Net Framework Data Provider" error in some client's machines.
Please suggest me what should i do to fix this.
System.Data.SQLite.dll completely depends on native library - 'sqlite3.dll'. So, you should install proper package on each machine, either x32 version or x64, and create two builds of the application - for x32 architecture and x64.
You can find more information about package types and its dependencies here in the Package Types section.
I developed a windows application using Entity Framework and as a database, I used SQLite. I have no problem developing it until I add a setup project to my solution to make an installer file for my application and I add .net Framework 3.5 and .net Framework 4.0 and Windows Installer as prerequisite to install.
In other computers, installation is done successfully but when users try to execute the application, they receive this exception
Unable to find the requested .Net Framework Data Provider
I googled this exception and most of the answers talked about provider name tag in web.config. Can anyone help me?
You have to include the System.Data.SQLite.dll provider assembly in your installer package (or make them required in a click-once download app) and then you have to register the provider by adding it to the providers section in the config file.
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
</DbProviderFactories>