问题描述
我想在我的项目中使用PostgreSQL数据库。我想学习code首先发展论坛..我下载的dotConnect PostgreSQL的(试用版),我加Devart.Data.PostgreSql DLL来我引用。然后,我添加了这些行我app.copnfig
I am trying to use POstgreSQL database in my project.I would like to learn code first developement..I download dotconnect for PostgreSql (trial version) and I added Devart.Data.PostgreSql dll to my references. Then, I added those lines in my app.copnfig
<connectionStrings>
<add name="SchoolDBConnectionString" connectionString="Server=localhost;Port = 5432;Database=MyDataBase;user Id=postgres;password=*****" providerName="Devart.Data.PostgreSql" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="Devart.Data.PostgreSql" />
<add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version= 6.8.333.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>
</system.data>
</configuration>
当我执行我的应用我有这个exeption:
WHen I execute my application i have this exeption :
同时获得从数据库提供信息时出错。这可以通过实体框架的使用不正确的连接字符串引起的。检查内部异常的详细信息,并确保连接字符串是正确的。
An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.
推荐答案
尝试添加这样(未测试)
Try to add this (Not tested)
<provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices,
Devart.Data.PostgreSql.Entity, Version=7.1.26.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
和
<entityFramework>
<providers>
<provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices,
Devart.Data.PostgreSql.Entity, Version=7.1.26.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</providers>
</entityFramework>
注意:更换7.1.26.6与实际装配的版本
Note: Replace 7.1.26.6 with the actual assembly version.
这篇关于如何使用的dotConnect为PostgreSQL和实体框架code第一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!