-1

EF Database models (.edmx) files are not opening in special VS EF data model designer. Just standard XML editor is working. All happening in VS2017 at win 10 (64).

Here is the declaration of the EDMX file

<Edmx Version="3.0" xmlns="http://schemas.microsoft.com/ado/2009/11/edmx"> 

This is the line where I have the issue

<Schema Namespace="CodeFirstDatabaseSchema" Provider="System.Data.SqlServerCe.4.0" ProviderManifestToken="4.0" Alias="Self" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl"`>

I have this problem:

"Severity Code Description Project File Line Suppression State Error Error 175: The ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details. SmartStore.Web D:\Dev\HMZ\RC5.0\builds\SmartStoreNET-3.x\src\Presentation\SmartStore.Web\App_Data\EfCache\SmartStore.Data.SmartObjectContext.edmx 5552"

most of the solutions found on the web won't work.

Please, people, help me with this. So terrible, experience. I'm trying to solve this problem 3-4 days.

I tried most of those answers I could find over the web: like updating/re-installing the SQL Compact, editing web.config provider factories, and etc.

Web Config (MVC 5/.NET 4.7.2)

 <DbProviderFactories>
    <remove invariant="System.Data.SqlServerCe.4.0" />
    <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" />
    <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.111.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
  </DbProviderFactories>
  <!-- Add the attribute 'codeConfigurationType' to the 'entityFramework' root element to overwrite the global DbConfiguration -->
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="System.Data.SqlServerCe.4.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
    </providers>
  </entityFramework>
A. Nadjar
  • 2,440
  • 2
  • 19
  • 20

1 Answers1

1

According to the Error you edited above:

'System.Data.SqlServerCe.4.0' is either not registered in the machine or application config file, or could not be loaded.

it can be a good idea to remove the dll for System.Data.SqlServerCe and add it again:

  1. install Microsoft SQL Server Compact 4.0
  2. Right click the References folder and select Add Reference... option. Go to the Assemblies | Extensions option on the left pane, then scroll to System.Data.SqlServerCe in the right pane. (or through the Browse button go to the installation directory and select the dll)

You might try these 3 solutions:

  1. Firstly, you can use one of the online XML parsers (eg. https://onlinexmltools.com/validate-xml) to make sure the XML is correct. If any errors exist, removing that section will fix the issue and the model will be shown after Clean and Rebuild.
  2. right-click the edmx file-> choose Open with->choose ADO.NET Entity Data Model Designer
  3. You can also fix it by deleting the file and regenerating it again.
  4. On the Visual Studio Installer, Click Modify, Select Individual Components tab, and make sure Entity Framework Under SDKs, libraries, and framework check-box is selected. Make sure you re-start visual studio.
A. Nadjar
  • 2,440
  • 2
  • 19
  • 20
  • I'm talking about the 1st option. watch out, here is the line in the .edmx where I have the issue it's the root for the whole database entities? by removing this one I remove all DB's entities. Is any way, how to deal with this line? Can I comment something partially but left this line in the place? – Denis Homez Aug 24 '19 at 21:26
  • Ok, let me check it. But meanwhile, isn't it possible to remove edmx from solution explorer and add your connection to dB via EF data entity wizard again? – A. Nadjar Aug 25 '19 at 03:23
  • A. Nadjar it is not possible. Temporarily, at this moment of time, there is no the DB. – Denis Homez Aug 27 '19 at 04:09
  • Is any way to check if the "Microsoft SQL Server Compact 4.0" installed correctly? – Denis Homez Aug 27 '19 at 04:11
  • Please sorry, in which way to remove the .dll System.Data.SqlServerCe? By using the VS2017 referencing tool or delete it manually out the FS folder? – Denis Homez Aug 27 '19 at 04:14
  • You can remove it either way (FS folder or solution explorer -> References) and add it again via Nuget. – A. Nadjar Aug 27 '19 at 04:19