Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法检索连接MVC3 EF和Postgres 9.1的元数据_C#_Asp.net Mvc 3_Entity Framework_Postgresql_Npgsql - Fatal编程技术网

C# 无法检索连接MVC3 EF和Postgres 9.1的元数据

C# 无法检索连接MVC3 EF和Postgres 9.1的元数据,c#,asp.net-mvc-3,entity-framework,postgresql,npgsql,C#,Asp.net Mvc 3,Entity Framework,Postgresql,Npgsql,我正在尝试将我的MVC3项目与Postgres 9.1中的数据库连接起来,我遵循以下链接:,从外观上看,我只需要字符串连接就可以创建控制器 我有对Mono.Security和Npgsql.dll的引用,我将它们添加到程序集中 我正在使用此连接字符串: <connectionStrings> <add name="TestPostgreSQLContext" connectionString="metadata=res://*/Mode

我正在尝试将我的MVC3项目与Postgres 9.1中的数据库连接起来,我遵循以下链接:,从外观上看,我只需要字符串连接就可以创建控制器

我有对
Mono.Security
Npgsql
.dll的引用,我将它们添加到程序集中

我正在使用此
连接字符串

<connectionStrings>
    <add name="TestPostgreSQLContext"         
         connectionString="metadata=res://*/Models.TestPostgreSQL.csdl|res://*/Models.TestPostgreSQL.ssdl|res://*/Models.TestPostgreSQL.msl;provider=Npgsql.NpgsqlConnection;provider connection string=&quot;data source=localhost;initial catalog=testPostgres;persist security info=True;user id=postgres;password=123456;multipleactiveresultsets=True;App=EntityFramework&quot;" 
         providerName="Npgsql.NpgsqlConnection"/>
</connectionStrings>
这里有一个更形象的想法:
您是否在应用程序的配置文件或machine.config中声明Npgsql为注册提供商?(见

public TestPostgreSQLContext() : base("name=TestPostgreSQLContext", "TestPostgreSQLContext")
{            
    this.ContextOptions.LazyLoadingEnabled = true;
    OnContextCreated();
}
public TestPostgreSQLContext(string connectionString) : base(connectionString, "TestPostgreSQLContext")
{
    this.ContextOptions.LazyLoadingEnabled = true;
    OnContextCreated();
}
public TestPostgreSQLContext(EntityConnection connection) : base(connection, "TestPostgreSQLContext")
{
    this.ContextOptions.LazyLoadingEnabled = true;
    OnContextCreated();
}