生成 .ADO.net 实体数据模型时,postgresql 不会出现在数据源中 [英] postgresql does not appear in Data Source when generating .ADO.net Entity Data Model

查看:21
本文介绍了生成 .ADO.net 实体数据模型时,postgresql 不会出现在数据源中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我直接使用 npgsql 成功访问了现有的 postgresql 数据库.我用于此:

I succeeded in accessing an existing postgresql dbase by using npgsql directly. I used for this:

  1. PostgreSQL 9.0.10(32 位)
  2. Visual Studio 2015 社区(64 位)
  3. NpgSql 2.2.5(通过管理Nuget 包)

然而,dbase 有 25 多个表和 400 多个列,因此我的意图是使用实体框架 + .ADO.net 实体数据模型以避免必须对所有列进行代码访问.我在这个站点上搜索并尝试了所有内容,npgsql 站点 http://www.npgsql.org/doc/ddex.html, ... 但是 II 没有成功生成 .ADO.net 实体数据模型,因为 postgresql 没有出现在数据源中.

The dbase however has 25+ tables and 400+ columns and such my intention is to to use entity framework + .ADO.net Entity Data Model to avoid having to code access to all columns. I searched and tried everything on this site, npgsql site http://www.npgsql.org/doc/ddex.html, ... but I I did not succeeded in generating an .ADO.net Entity Data Model because postgresql does not appear in Data Source.

我用过这个:

  1. PostgreSQL 9.0.10(32 位)
  2. Visual Studio 2015 社区(64 位)
  3. NpgSql 2.2.5(通过管理 Nuget 包)
  4. Setup_Npgsql-2.2.5.0-r3-net45.exe(来自 GitHub,因为有些网站表示要求在GAC中有相同的版本作为visual studio项目中使用的包;我没有拿版本3.0.0,因为 Github 缺少安装文件).
  5. Npgsql.entityframework6 2.2.5(通过管理 Nuget 包)
  6. Entityframework 6.1.3(通过管理 Nuget 包)

在尝试生成 .ADO.net 实体数据模型时,我需要做什么才能使 postgresql 显示为数据源?
还是 Visual Studio 2015 社区不允许为 postgresql 生成 .ADO 网络实体数据模型?

What do I have to do so postgresql appears as Data Source when trying to generate an .ADO.net Entity Data Model?
Or does Visual Studio 2015 community does not allows the generation of .ADO net entity data model for postgresql ?

编辑我已经添加了以下信息,希望得到回复:

EDIT I have added the following info in the hope for a reply:

使用 Microsoft Windows 8.1 6.3.9600 build 9600 64 位

Microsoft Windows 8.1 6.3.9600 build 9600 64-bit used

提取C:WindowsMicrosoft.NETFrameworkv4.0.30319Configmachine.config"

Extract out "C:WindowsMicrosoft.NETFrameworkv4.0.30319Configmachine.config"

<system.data>
    <DbProviderFactories>
        <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
    </DbProviderFactories>
</system.data>

提取C:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config"

Extract out "C:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config"

<system.data>
    <DbProviderFactories>
        <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
    </DbProviderFactories>
</system.data>

Visual Studio - packages.config"

"Visual Studio - packages.config"

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net452" />
  <package id="Npgsql" version="2.2.5" targetFramework="net452" />
  <package id="Npgsql.EntityFramework" version="2.2.5" targetFramework="net452" />
</packages>

Visual Studio - App.config"

"Visual Studio - 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.2" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

推荐答案

因为同样的问题,我困惑了 3 天.

I was confused while 3 days becuase the same problem.

但是,我发现解决了这个问题:

But, I found solve this problem:

  1. 在您的 Visual Studio 环境中安装 .vsix 文件.https://github.com/npgsql/npgsql/releases/tag/v3.1.8 (NpgsqlDdexProvider)

  1. install .vsix file in your visual studio environment. https://github.com/npgsql/npgsql/releases/tag/v3.1.8 (NpgsqlDdexProvider)

通过 Nuget 包管理器安装 Npgsql 和 EntityFramework6.Npgsql.

install Npgsql and EntityFramework6.Npgsql by Nuget Package Manager.

构建您的项目.(适用于 Nuget 修改 App.xaml 的配置)

Build your project. (For apply configuration of modified App.xaml by Nuget)

您可以使用 ADO.NET 实体模型生成.

You can use ADO.NET Entity Model Generation.

此外,dotConnect 不支持 Express 版本中的实体模型.仅支持商业版.

Also, dotConnect not support Entity Model in Express version. It supported in only commercial version.

但目前,Npgsql 已立即关闭 EDM 中的错误.所以,我找到了解决方案.

But currently, Npgsql has immediately close bug in EDM. so, I finding solution.

这篇关于生成 .ADO.net 实体数据模型时,postgresql 不会出现在数据源中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆