简体   繁体   中英

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

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM