I'm trying to connect my MVC3 project to a database in Postgres 9.1, I follow these links: info1 , info2 , info3 and for its appearance I only need a string connection to create a controller.
I have a link to Mono.Security
and Npgsql
.dll, I add them to the assembly
I am using this 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>
Code Markup:
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(); }
Here's a more graphical idea:
source share