ijon
ijon

Reputation: 111

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

In my VS2013 project with reference to:

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

Upvotes: 4

Views: 12095

Answers (2)

CodingYoshi
CodingYoshi

Reputation: 27019

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.

Upvotes: 0

Trinitron
Trinitron

Reputation: 384

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

Upvotes: 6

Related Questions