4

I'm using the SQL Server Compact/SQLite Toolbox for Visual Studio by ErikEJ. Environment is Windows 7 x64 with Visual Studio 2013.5

I'm following along in the example on the blog http://erikej.blogspot.dk/2013/11/entity-framework-6-sql-server-compact-4_25.html but when I get to

" ... connect to the database file in your project folder:",

I right click to "Add SQL Server Compact/SQLite Connection" and the box comes up, but at the bottom is in red

"Cannot save this connection for use with EF6 Tools, make sure the SQL Server Compact DbProvider is installed, and possibly restart Visual Studio"

I go back and click on the About button and get

SQL Server Compact 4.0 in GAC - Yes - 4.0.8482.1 
SQL Server Conpact 4.0 DbProvider - No

SQL Server Compact 4.0 DDEX provider - No 
SQL Server Compact 4.0 Simple DDEX provider - Yes
SQL Server Compact 4.0 Engine Test: PASS!

I've uninstalled SQL Server Compact and the SQL Server Compact Toolbox and reinstalled both but I still have the same error.

I'm wondering how do I get SQL Server Compact 4.0 DbProvider to be yes?

Thanks

Edit I've added the details of the relevant part of machine.config that could contain invalid entries.

<system.data>
    <DbProviderFactories>
        <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <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>
</system.data>

I've checked the above against an example here https://developer.teradata.com/blog/netfx/2010/12/dbproviderfactories-demystified and I can't see anything obviously wrong with that part.

Aha. I was looking in the wrong place. Under C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config I have

<system.data>
    <DbProviderFactories><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>
</system.data>

hmmm ... the other ones are missing.

Alan
  • 306
  • 2
  • 10
  • 1
    Remove and reinstall SQL Server Compact 4.0 in order to update your machine.config file – ErikEJ Aug 30 '15 at 17:20
  • Thanks for your quick response!! I've closed down VS2013, gone to control panel to uninstall "Microsoft SQL Server Compact 4.0 x64 ENU". Install "Microsoft SQL Server Compact 4.0 x64 ENU". Open up VS2013. SQL Server Compact Toolbox still says DbProvider as No. I'm just going to google machine.config! – Alan Aug 30 '15 at 17:30
  • Your x86 machine.config could have invalid entries in the dbproviderfactories section – ErikEJ Aug 30 '15 at 17:43
  • I found machine.config under C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG. I'll update the question with details. – Alan Aug 30 '15 at 17:44
  • You are looking in the wrong place, VS 2013 uses .net 4,5 - C:\Windows\Microsoft.NET\Framework\v4.0.30319 – ErikEJ Aug 30 '15 at 18:38
  • I've updated the question with details from C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config. – Alan Aug 30 '15 at 18:59

2 Answers2

4

OK, I've finally managed to get past this point.

I uninstalled Visual Studio 2013 and SQL Server Express. I had done this before using the procedure listed here https://dba.stackexchange.com/questions/68373/how-to-uninstall-sql-server-2012-not-showing-in-control-panels-programs-and-fe for the sql server and here How to completely uninstall Visual Studio 2010? using

D:\vs_community.exe /uninstall /force

I had done this before and reinstalled VS2013.5 but I came up with the above error which prompted this question. So following further advice from the above pages I did

wmic product where "name like 'microsoft visual studio%'" call uninstall /nointeractive
wmic product where "name like 'microsoft sql server%'" call uninstall /nointeractive

This cleared out stuff that had been left behind from before.

I also uninstalled using Revo Uninstaller and used that to scan for any remaining traces on the machine. This also picked up remnants that had been left behind.

After all that, I installed VS2013.5 again and I was able to have SQL Server Compact Toolbox recognize the database properly without error. I hope this helps anyone else who comes across the same problem.

Community
  • 1
  • 1
Alan
  • 306
  • 2
  • 10
0

I know, this is an old quest but may be this helps somebody.

I had similar issue, I got

Cannot save this connection for use with EF6 Tools, make sure the SQL Server Compact DbProvider is installed, and possibly restart Visual Studio

And as a result could not connect DataGrid component to the Database. In this case just dont forget about pretty cool button Register DDEX Providers provided by ErikEJ (many thanks to him)

enter image description here

Community
  • 1
  • 1
Ivan Talalaev
  • 6,014
  • 9
  • 40
  • 49