Error "Exception has been thrown by the target of an invocation" in VS2013

c# entity-framework sql-server-ce visual-studio-2013

Question

In my VS2013 project with reference to:

  • EntityFramework 6.1.3,
  • EntityFramework.SqlServerCompact (for SQLServerCompact 4.0)

I am facing an error in my edx file. VisualStudio says:

Exception has been thrown by the target of an invocation

and the edmx file cannot be opened or updated.

Anyone can help to solve the issue?

Here is the excerpt of app.config:

  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="Imir.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <connectionStrings>
    <add name="ImirDBEntities" connectionString="metadata=res://*/ImirDB.csdl|res://*/ImirDB.ssdl|res://*/ImirDB.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;Data Source=C:\ProgramData\Telesto\ImirDB.sdf&quot;"
      providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="System.Data.SqlServerCe.4.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
    </providers>
  </entityFramework>

A here is the beginning of my edmx file:

<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="ImirDBModel.Store" Alias="Self" Provider="System.Data.SqlServerCe.4.0" ProviderManifestToken="4.0" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
  <EntityContainer Name="ImirDBModelStoreContainer">
    <EntitySet Name="AuthUser" EntityType="ImirDBModel.Store.AuthUser" store:Type="Tables" />
    <EntitySet Name="AuthUserGrant" EntityType="ImirDBModel.Store.AuthUserGrant" store:Type="Tables" />
1
3
8/9/2015 2:01:47 PM

Accepted Answer

I got all the nuget packages installed for private deployment and however have the same error while opening EDMX diagrams.

Exception has been thrown by the target of an invocation.

Designer is not working with SqlServerCe.4.0 provider in app.config file. Try to remove this line temporary to make it open:

      <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
6
8/12/2015 11:01:18 AM

Popular Answer

In my case it was my connection string. Pay very close to your connection string, maybe copy and paste it into a console application and see if it works by getting one row from the database.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow