Add custom data source to visual studio 2015

时间:2015-06-25 18:58:20

标签: entity-framework postgresql visual-studio-2015

I want to use Entity Framework 6 to connect to PostgreSql database using Visual Studio 2015 (Entreprise). So i have used nuget to install: entityFramework npgsql npgsql.entityFramework 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> After that, i have tried to generate the edmx file of PostgreSql database: Right click on the project in visual studio 2015 Add new item Select "ADO.Net entity data model" object under "data" tab and "Entity Data Model Wizard" is there Select "EF designer from database" and click next Click new connection button Add i get the window "Choose data source" As you can see in the picture, there's no data source for PostgreSql. Is there something to set up with visual studio 2015?

2 个答案:

答案 0 :(得分:1)

问题是我应该第一次设置Visual Studio 2015以支持npgsql。完整设置位于http://www.npgsql.org/doc/ddex.html 可能是链接可以帮助别人

答案 1 :(得分:0)

对我来说,没有帮助在app.config中添加这样的字符串(甚至多次重新启动VS),但是在安装“ Npgsql PostgreSQL Integration Visual Studio”后帮助重新创建项目时,相同的行自动添加到了app.config中