gpt4 book ai didi

c# - Npgsql Entityframework - 看不到 ADO.net 实体数据模型的 Postgres 提供程序

转载 作者:行者123 更新时间:2023-11-29 12:25:18 24 4
gpt4 key购买 nike

我正在尝试将 Postgres 数据库连接到 EDMX 设计器。

我已经安装了 EntityFrameowrk6.npgsql block 模块,如下所述:http://www.npgsql.org/ef6/index.html (数据库已经有了uuid-ossp扩展名)

然后我安装了扩展包,如下所述:http://www.npgsql.org/doc/ddex.html

最后,我将 npgsql 模块更新为 v3.2.1 以匹配集成文档中建议的扩展版本。

我可以使用 visual studio 的服务器浏览器连接到我的数据库。

完成此操作后,我已将 ado.net 实体数据模型添加到我的项目中,但他对我可用的唯一提供程序是 Microsoft sql 的。看不到 Postgres!

我正在运行 Visual Studio Community 2017,它是完全最新的,唯一安装的其他扩展是 AnkhSVN。这是一个当前为 .net 4.5.1 配置的 C# 项目(但我非常高兴并愿意更改目标框架以使一切正常工作!)

我的项目中唯一的 Nuget 包是上面描述的那些及其依赖项。

很多谷歌搜索结果只是各种教程告诉我基本上做上面的事情,或者人们向 app.config 添加元素(我已经尝试过但失败了,然后恢复了)npgsql 文档明确指出你不应该需要做的。

非常感谢任何帮助!

编辑:这是我目前的 App.Config。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<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 -->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.2.1.0" newVersion="3.2.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

最佳答案

原来我遇到的问题是我在添加 NuGet 后没有重建我的项目/解决方案。主要是因为我正在用 Postgre 替换旧的 SQL EF 实现,并且由于大量缺少引用而无法构建。

这里的问题表明重建是应该发生的事情:Entity Framework 6.1.1 and Npgsql 2.2.3: Compatible Entity Framework database provider could not be found

因此,我注释掉了我的大部分代码,重新构建,并且提供程序出现在我期望的位置。

使 Visual Studio 崩溃(嘶嘶声!),但这是一个单独的问题。

我希望这对一些可怜的人有帮助。

关于c# - Npgsql Entityframework - 看不到 ADO.net 实体数据模型的 Postgres 提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42858144/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com