Failed to get metadata linking MVC3 EF to Postgres 9.1

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=&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> 

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: enter image description here

+4
source share
1 answer

Have you declared Npgsql as a registered provider, in your application configuration file or inside machine.config? (see this official Npgsql documentation

+2
source

Source: https://habr.com/ru/post/1416246/


All Articles