还有一个 "Unable to find the requested .Net Framework Data Provider. It may not be installed"

Yet another "Unable to find the requested .Net Framework Data Provider. It may not be installed"

我有一个 ASP.NET 网页,但收到以下错误:

System.ArgumentException: 'Unable to find the requested .Net Framework Data Provider. It may not be installed.'

WebSecurity.InitializeDatabaseConnection("ALMSTEntities", "UserProfile", "UserId", "EmailAddress", autoCreateTables: true);

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

<connectionStrings>
    <add name="ALMSTEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=ALMST;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>

<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>

我不知疲倦地搜索并尝试了很多方法来解决这个问题。这个错误似乎很常见,有很多不同的答案,但 none 对我有用。这不是重复的,因为本网站和其他网站提供的所有其他答案都没有解决我的问题。

我该如何解决这个问题?

用以下内容替换问题中的连接字符串为我解决了这个问题:

<add name="ALMSTDB" connectionString="Data Source=DESKTOP-99CRCTP\SQLEXPRESS;Initial Catalog=ALMST;Integrated Security=True" providerName="System.Data.SqlClient"/>

使用以下提供商:

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