ADO.NET空Designer.cs

时间:2018-08-08 05:24:50

标签: c# asp.net ado.net npgsql

在Visual Studio 2017版本15.7.4中,我具有带有PostgresQL数据库的asp.net项目。当我使用PostgresQL创建ADO.NET实体数据模型时,它将正确地创建.edmx [Diagram]对象,但在MyModel.Designer.cs中什么都没有显示:

//为模型'C:\ Users \ User \ Desktop \ Alibek1 \ Alibek1 \ Model1.edmx'启用了T4代码生成。 //要启用旧代码生成,请更改“代码生成策略”设计器的值 //属性为“旧版ObjectContext”。当模型出现时,此属性在“属性”窗口中可用 //在设计器中打开。

//如果未生成任何上下文和实体类,则可能是因为您创建了一个空模型,但是 //尚未选择要使用哪个版本的Entity Framework。生成上下文类和实体 //您的模型的类,在设计器中打开模型,右键单击设计器表面,然后 //选择“从数据库更新模型...”,“从模型生成数据库...”或“添加代码生成” //项目...'。

当我在Model1.edmx中单击“从模型生成数据库”时,显示错误:

enter image description here

那是这样的:不变名称为“ Npgsql”的ADO.NET提供程序未在计算机或应用程序配置文件中注册,或者无法加载。

这是我的Web.config的某些部分:

`    <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>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Server=localhost;user id=postgres;password=123;database=postgres;" providerName="Npgsql" /><add name="Model1" connectionString="Host=localhost;Database=postgres;Username=postgres;Persist Security Info=True;Password=123" providerName="Npgsql" /><add name="postgresEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Npgsql;provider connection string=&quot;Host=localhost;Database=postgres;Username=postgres;Password=123&quot;" providerName="System.Data.EntityClient" /><add name="postgresEntities1" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Npgsql;provider connection string=&quot;Host=localhost;Database=postgres;Username=postgres;Password=123;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" /><add name="postgresEntities2" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Npgsql;provider connection string=&quot;Host=localhost;Database=postgres;Username=postgres;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" /><add name="postgresEntities3" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Npgsql;provider connection string=&quot;Host=localhost;Database=postgres;Username=postgres;Password=123;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" /></connectionStrings>
  <system.data>
    <DbProviderFactories>
    <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"/>
    <add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version= 7.11.1190.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>`
` <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>`
` <providers>
     <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity.EF6, Version=7.11.1190.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider></providers>    ` 

0 个答案:

没有答案
相关问题