C# 无法检索连接MVC3 EF和Postgres 9.1的元数据
我正在尝试将我的MVC3项目与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
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="data source=localhost;initial catalog=testPostgres;persist security info=True;user id=postgres;password=123456;multipleactiveresultsets=True;App=EntityFramework""
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();
}