Я пытаюсь соединить мой MVC3 проект с базой данных в Postgres 9.1, Я следовать этой ссылке: info1, info2, info3 и внешний вид этого, я только необходимо создать строковое соединение, чтобы создать контроллер.Невозможно получить метаданные, соединяющие MVC3 EF с Postgres 9,1
У меня есть ссылка на .dll Mono.Security
и Npgsql
, я добавляю их Ассамблее
Я использую этот 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();
}
Вот еще графическая идея: