Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Basics Introducing Entity Framework Using the Context

Andras Somodi
Andras Somodi
9,229 Points

An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.dll

"Additional information: Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config."

I have MSSSQLLocalDB installed, so what am I missing?

Andras Somodi
Andras Somodi
9,229 Points

I managed to solve this for myself, but since this might come up for others I will briefly explain how. It probably has to do with having other Database managers on your windows installed in my case MySql for example. This messes with the machine.config file in your Windows\Microsoft.NET\Framework64 and Windows\Microsoft.NET\Framework folders when you install visual studio. In these files (I had 2 in each folder) wrong xml tags might be generated like this:

<system.data> <DbProviderFactories> <add name="IBM DB2 for i .NET Provider" invariant="IBM.Data.DB2.iSeries" description=".NET Framework Data Provider for IBM i" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26"/>

<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/></DbProviderFactories>
<DbProviderFactories/>

</system.data>

Notice that there is an additional <DbProviderFactories/> tag at the end. I removed these from all files. I also removed the line for MySQL since I do not use that anymore, although I do not know which change actually solved the problem. It works now.

1 Answer

Steven Parker
Steven Parker
231,248 Points

Congratulations on resolving your issue. :+1:

That was a tricky one!