Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Data First: Unable to find the requested .net framework provider #69

Closed
vanceism7 opened this issue Apr 6, 2017 · 3 comments
Closed

Comments

@vanceism7
Copy link

vanceism7 commented Apr 6, 2017

So I've been trying to troubleshoot this error for just a day or so now, and I've narrowed it down to the app.config. I installed the npgsql vsix extension from the visual studio market place. This allowed me to see the postgres provider in the server explorer, but it wouldn't show up in the EF Model generator update wizard.

When I use nuget to install EntityFramework6.Npgsql, the app config that gets generated automatically then inserts that postgres provider option in the update wizard, but it must be incorrect because when I use it, it gives the message upon trying to connect:
"Unable to find the requested .net framework provider, it may not be installed".

So Im assuming the bigger issue here is that the update wizard isn't respecting the vsix installation, but it may also be an issue that my app config gets a dbprovider entry when I install the entityframework6.npgsql package. Or perhaps the app.config is supposed to reference the work done by the vsix. (I'm not really sure how the internals of vsix and providers and all that work here, so Im just making assumptions)

Heres the dbprovider entry that gets created in my app.config when I install the package. If I remove the npgsql line, then the provider disappears out of the list of providers. If I leave it in, then it shows in the list but says the provider isn't found when you try to use it

<providers>
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
</providers>

Anyways, any assistance here just to get the data model to generate would be great. Thanks!

P.S: This is a fresh install of using npgsql, I never modified the GAC or anything like that. I started off with the vsix

@vanceism7
Copy link
Author

Ok I figured out a little bit more about this. If I try to add the database connection from the server explorer, the data providers there do respect the vsix install and Im able to connect to the database. But from the ef data wizard, the vsix provider isn't visible. Also, something about installing the nuget packages will also cause the server explorer to have the same error as the ef data wizard unless I restart visual studio.

If I add the database connection from server explorer, and then go into the ef data wizard, then my connection will show up in there and work. (Atleast the 2nd time I tried this, it did. The first time, it still didnt see the connection but now it is seeing it)

@vanceism7
Copy link
Author

vanceism7 commented Apr 8, 2017

Nvm: as per issue 1439, I'm assuming that entity frameworks model wizard is probably using the ADO.NET DbProviderFactory API, which doesn't care about the vsix. This would explain why the server explorer can see the provider but not the ado.net model generator.

Basically the solution is summed up as this:
You have to use the GAC modification with the app.config modified for the model generator to work correctly.

Here's issue 1439 for reference
npgsql/npgsql#1439

@cosmoKrick42
Copy link

cosmoKrick42 commented Jan 31, 2022

I've tried adding same code in app.config but still facing same issue.
Help me out

<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="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
		</providers>
	</entityFramework>`

<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>

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants