4
我想我的MVC3項目與數據庫中的Postgres 9.1連接,我已經按照這個鏈接:info1,info2,info3和它的外觀,我只需要字符串連接爲了創建一個控制器。無法檢索連接MVC3 EF元數據的Postgres 9.1
我有參考Mono.Security
和Npgsql
.dll文件,我將它們添加到大會
我使用這個connectionString
:
<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>
代碼標籤:
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();
}
下面是一個更加圖形化的想法: