将自定义数据源添加到Visual Studio 2015 [英] Add custom data source to visual studio 2015

查看:195
本文介绍了将自定义数据源添加到Visual Studio 2015的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Entity Framework 6通过Visual Studio 2015(企业版)连接到PostgreSql数据库。

I want to use Entity Framework 6 to connect to PostgreSql database using Visual Studio 2015 (Entreprise).

所以我用nuget来安装:

So i have used nuget to install:


  • entityFramework

  • npgsql

  • npgsql.entityFramework

然后我修改了如下的app.config:

Then i have modified the app.config like below:

<system.data>
    <DbProviderFactories>
      <clear />
      <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
    </DbProviderFactories>
  </system.data>
<entityFramework>
    <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
    </providers>
   <defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql" />
  </entityFramework>

在那之后,我尝试生成PostgreSql数据库的edmx文件:

After that, i have tried to generate the edmx file of PostgreSql database:


  1. 在Visual Studio 2015中右键单击项目

  2. 添加新项

  3. 在数据选项卡下选择 ADO.Net实体数据模型对象,然后在实体数据模型向导中找到

  1. Right click on the project in visual studio 2015
  2. Add new item
  3. Select "ADO.Net entity data model" object under "data" tab and "Entity Data Model Wizard" is there

  1. 选择 EF从数据库设计器,然后单击下一步

  2. 单击新的连接按钮
    添加我得到窗口选择数据源


如图所示,没有PostgreSql的数据源。
是否可以使用Visual Studio 2015进行设置?

As you can see in the picture, there's no data source for PostgreSql. Is there something to set up with visual studio 2015?

推荐答案

我应该设置Visual Studio 2015第一次支持npgsql。完整的设置在这里 http://www.npgsql.org/doc/ddex.html
可能是链接可以帮助其他人

The thing is i should setup Visual Studio 2015 the first time to support npgsql. The full setup is here http://www.npgsql.org/doc/ddex.html May be the link could help someone else

这篇关于将自定义数据源添加到Visual Studio 2015的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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