具有固定名称“System.Data.SqlClient;”的 ADO.NET 提供程序找不到(实体框架 MVC)

2023-11-30

我似乎无法解决 Entity Framework 6 的常见问题。我已经在 SO 上查看了与此问题相关的许多主题,并且无法找到适合我的特定情况的解决方案。

到目前为止,我一直在使用 localdb 和代码优先迁移进行开发,效果很好。但现在我将其移动到实际的 SQL Server 实例,它在尝试迁移时抛出以下错误:

“具有固定名称“System.Data.SqlClient;”的 ADO.NET 提供程序未在计算机或应用程序配置文件中注册,或者无法加载。有关详细信息,请参阅内部异常。 在System.Data.Common.DbProviderFactories.GetFactory(字符串providerInvariantName)“

我尝试了以下修复:

1)卸载并重新安装实体框架

2)添加了code并使用:

public abstract class BaseDomainContext : DbContext
{
    static BaseDomainContext()
    {
        // ROLA - This is a hack to ensure that Entity Framework SQL Provider is copied across to the output folder.
        // As it is installed in the GAC, Copy Local does not work. It is required for probing.
        // Fixed "Provider not loaded" error
        var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
    }
}

作为我的 DbSet 类的基类。

3)将所有内容添加到新的解决方案中并收到相同的错误。

4)删除写入上下文并尝试仅读取迁移,仍然失败。

5)尝试使用来自的信息进行多次重写MSDN

6)我已确认EntityFramework.SqlServer.dll位于我的bin目录中。它也被正确引用。另外,我的解决方案下只有一个项目。

7)确认我没有在视图下使用WebConfig。

8) 确认 bin 文件夹中有 System.Data dll。

Image of bin folder

在上述每个步骤之后完成清理/重建和删除现有迁移文件夹。

我无法解释为什么我仍然收到此错误。

网页配置

    <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 --></configSections>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <connectionStrings>

    <add name="ReadContext" connectionString="Server=Sql2014intsnace;Database=database;User Id=secret; Password=secret;" providerName="System.Data.SqlClient;" />
    <add name="WriteContext" connectionString="Server=Sql2014intsnace;Database=database;User Id=secret; Password=secret;" providerName="System.Data.SqlClient;" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Windows" />
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
  <system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />    
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
    <contexts> 
  <context type="ProjectName.Models.ReadContext, ProjectName"> 
    <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[ProjectName.Models.ReadContext, ProjectName], [ProjectName.Migrations.Configuration, ProjectName]], EntityFramework" /> 
  </context> 
</contexts>
  </entityFramework>
</configuration>

你有这个:

<add name="ReadContext" 
     connectionString="Server=Sql2014intsnace;Database=database;User Id=secret; Password=secret;" 
     providerName="System.Data.SqlClient;" /> <-- semi-colon

应该是这样的:

<add name="ReadContext" 
     connectionString="Server=Sql2014intsnace;Database=database;User Id=secret; Password=secret;" 
     providerName="System.Data.SqlClient" /> <-- no semi-colon

否则,您将告诉 ADO 查找名为System.Data.SqlClient;- 没有一个。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

具有固定名称“System.Data.SqlClient;”的 ADO.NET 提供程序找不到(实体框架 MVC) 的相关文章

随机推荐

  • 如何使用 nextjs 处理获取 URL

    因此 我尝试将 nextjs 应用程序部署到 vercel 但它在代码的索引获取 URL 部分始终失败 在我的index js页面目录的文件我有以下代码 export async function getStaticProps const
  • Zend Framework:无法确定临时目录,请手动指定cache_dir

    我刚刚学习 Zend 框架 我创建了一个简单的 Zend Form 当我提交表单时 出现以下错误 An error occurred Application error Exception information Message Could
  • Xcode 4.2 中的 Guard Malloc。它在哪里?

    它在哪里 Xcode 中还有其他可用的工具吗 谢谢 现在 NDA 不再适用于 xcode 4 2 以下是包含所需步骤的屏幕截图 对于仍在寻找 Guard Malloc 的人来说 这应该会更快
  • 如何将各种类型的函数指针存储在一起?

    普通指针可以使用通用存储void e g void arr 10 arr 0 pChar arr 1 pINt arr 2 pA 不久前 我看到一个讨论 void 可能无法在所有平台 例如 64 位及更多 中存储函数指针而不丢失数据 但我不
  • 使用java插入二叉树不起作用

    我目前正在使用java学习树 我这里发生了一些错误 在二叉树中插入项目 我不明白为什么它不起作用 这是代码 树节点 public class TNode int data TNode left TNode right public TNod
  • 更新 AppWidget 上的 TextView 文本大小

    我无法弄清楚这一点 我已经为此苦苦挣扎了好几天 我已经厌倦了 我正在使用配置活动中的 Spinner 更改 AppWidget 上 TextView 的文本大小 但无法正确更新 我告诉它第一次时它不会更新 但第二次和第三次以及之后的每次都会
  • 如何测试网页是否包含某些文本

    我正在尝试检测网页是否包含某些文本 例如 我想看看是否这个网页包括以下短语 这是我的代码 我无法发现 如果那么 条件得到满足 这就是我正在尝试的 Const READYSTATE COMPLETE 4 Declare Function Se
  • 列表视图在视图翻转器内滑动

    我试图在列表视图上左右滑动并切换视图翻转器 就像 remeberthemilk 应用程序以及 Nexus One 上的默认新闻和天气应用程序一样 滑动浏览新闻主题 使用我找到的各种教程 我在 stackoverflow 上发现了一个展示如何
  • 无法通过c#删除.exe文件

    我在 Windows 窗体应用程序中有一个更新按钮 当用户单击更新按钮时 应用程序会检查应用程序的当前版本与从 Web 服务获取的服务器中的可用版本 如果版本不匹配 应用程序将从Web服务获取的路径下载新版本 我目前在同一解决方案中使用两个
  • 运行jsp文件时出现错误

    我在 eclipse juno 中创建了一个简单的 Hello jsp 程序 当我尝试通过在服务器上运行来运行此 jsp 文件时 出现以下错误 出现问题 在本地主机上发布到 Tomcat v6 0 服务器 遇到了问题 发布失败并出现多个错误
  • 使用 pandas python 的 SuperTrend 代码

    我正在尝试使用 pandas 在 python 中为 SuperTrend 指标编写以下算法 BASIC UPPERBAND HIGH LOW 2 Multiplier ATR BASIC LOWERBAND HIGH LOW 2 Mult
  • 尝试将内联 UIDatePicker 添加到 UITableViewCell

    我正在尝试在 TableView 单元格内创建一个内联 DatePicker 类似于this and this所以线程 我使用下面的方法创建日期选择器 该方法在加载视图时调用 void createDatePicker datePicker
  • 在 sql 查询中使用数组/变量

    我确信有办法做到这一点 但我不知道了 我有一张包含所有数据的大表 In the table I包含以下信息的行 columnA1 groupName columnA2 groupID ColumnB3 name columnB4 group
  • Tomcat 8 中的 SSL:服务器和客户端 JKS + 客户端公共 cer

    我按照本指南使用 SSL 层设置 Tomcat 8 实例 生成客户端和服务器密钥库以及自动签名的公共客户端证书 我想问题是我真的不知道如何配置 Tomcat 的连接器 这是我当前的 server xml 文件 删除了不必要的注释
  • 在 Django 中序列化一棵树

    有没有简单的方法来序列化由模型给出的树 例如下面所示的类别 我想得到一个 json 对象 例如 name cat1 children name cat11 children Thanks class Category MPTTModel n
  • 如何使用 mallet 获得单词主题概率

    我使用 mallet 制作了一个并行主题模型 我想获得每个文档的热门词 为此 我试图获取单词主题概率矩阵 我将如何实现这一目标 当您使用 MALLET 构建主题时 您有一个选项称为 word topic counts file 当您提供此选
  • c++20范围库,如何使条件运算符起作用?

    对标题表示歉意 如果我知道如何更好地表达它 那么谷歌可能已经帮助了我 我想要一个对象 Y 它代表容器 X 的视图 这样当我迭代 Y 时 它要么是 X 的前向迭代 要么是后向迭代 我想在不复制数据的情况下执行此操作 因此新的ranges我想到
  • SimpleFramework XML:具有内部文本和子元素的元素

    我在使用无法更改的特定格式的 SimpleFramework 反序列化 xml 时遇到以下情况
  • 删除文件上传时的文件扩展名

    我现在正在为一个网站编写代码 该网站上传图像 然后以图库样式显示它们 我想要发生的是将图像的文件名作为图像的名称输入到站点的数据库中 然而 仅仅使用 FILES images name 给我文件名 但末尾附有文件扩展名 如何删除文件扩展名以
  • 具有固定名称“System.Data.SqlClient;”的 ADO.NET 提供程序找不到(实体框架 MVC)

    我似乎无法解决 Entity Framework 6 的常见问题 我已经在 SO 上查看了与此问题相关的许多主题 并且无法找到适合我的特定情况的解决方案 到目前为止 我一直在使用 localdb 和代码优先迁移进行开发 效果很好 但现在我将