VS2013 中的错误 "Exception has been thrown by the target of an invocation"

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

在我的VS2013项目中参考:

我的 edx 文件出现错误。 VisualStudio 说:

Exception has been thrown by the target of an invocation

并且无法打开或更新 edmx 文件。

有人可以帮忙解决问题吗?

以下是 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>

这是我的 edmx 文件的开头:

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

我为私人部署安装了所有 nuget 包,但是在打开 EDMX 图表时出现同样的错误。

调用的目标抛出异常。

Designer 未使用 app.config 文件中的 SqlServerCe.4.0 提供程序。 尝试暂时删除此行以使其打开:

      <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />

在我的例子中,它是我的连接字符串。支付非常接近您的连接字符串,也许将其复制并粘贴到控制台应用程序中,然后通过从数据库中获取一行来查看它是否有效。