App.Config-'System.Data.Entity.Migrations.DbMigrationsConfiguration`1'的类型初始值设定项引发了异常

时间:2019-04-24 11:00:32

标签: entity-framework

尝试添加迁移时出现此错误。 可能是什么问题? 我先使用EF代码。 以下是我的App.config文件-

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.public 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 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <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>
  <connectionstrings>
    <add name="CNUG"
         connectionstring="Data Source=haisqldev163\haisqldev163,3183;Initial Catalog=CNUG;Integrated Security=False;User ID=CNUG_admin;Password=@g8hWB!d"
    providerName="System.Data.SqlClient"/>
    <!--connectionpublic string="server=haisqldev163\\haisqldev163;port=3183;Initial Catalog=CNUG;Persist Security Info=True;User ID=CNUG_admin;Password=@g8hWB!d" providerName="System.Data.SqlClient" />-->
  </connectionstrings>
  <!--<system.data>
    <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" />
    </DbProviderFactories>
  </system.data>-->
</configuration>

我该如何解决?是什么引起了这个问题?

0 个答案:

没有答案