Hi,
when using Code-First with Migrations and another schema than public I get a "schema does not exist" Exception.
When using Code-First without Migrations the schema is created and everything works as intended.
Best Regards,
Dresel
Code-First Migrations: Does not create Schema
Re: Code-First Migrations: Does not create Schema
The "schema does not exist" error occurs when you use context.TestEntities.Create() with your sample from http://forums.devart.com/viewtopic.php?t=29842#p102684, doesn't it?
We cannot reproduce the issue with dotConnect for PostgreSQL v7.3.201. Please upgrade. If this doesn't help, give us the following information:
1) tell us how we should modify your sample for reproducing or send us a new small test project
2) which is SQL statement executed when the error occurs? (check via dbMonitor)
We cannot reproduce the issue with dotConnect for PostgreSQL v7.3.201. Please upgrade. If this doesn't help, give us the following information:
1) tell us how we should modify your sample for reproducing or send us a new small test project
2) which is SQL statement executed when the error occurs? (check via dbMonitor)
Re: Code-First Migrations: Does not create Schema
I have sent you the modified sample project.
I added the following to the context OnModelCreating:
I modified Migrations Down / Up to
I added the following to the context OnModelCreating:
Code: Select all
// Map to different schema
modelBuilder.Entity<TestEntity>().ToTable("TestEntity", "test");
Code: Select all
public override void Down()
{
// Map to different schema
DropTable("test.TestEntity");
}
public override void Up()
{
Console.WriteLine("Migrations called.");
// Map to different schema
CreateTable("test.TestEntity",
c => new { TestEntityID = c.Int(nullable: false, identity: true), TestEntityText = c.String(), })
.PrimaryKey(t => t.TestEntityID);
}
Re: Code-First Migrations: Does not create Schema
Thank you for the report. We have reproduced the issue and are investigating it.
Re: Code-First Migrations: Does not create Schema
In scope of current EF 6.1 architecture, we are limited in ability to process the scenario of creating database with the help of migrations because we do not have information about mapped objects of EF model in the moment of creating database with CreateDatabase() functionality. The only information we have access to is PgSqlConnection and its connection string.
So we create a database, specified in the Database connection string parameter, and a schema(s), which is set in the Schema connection string option.
And when DDL for migration is generated, we already do not have access to the actual connection.
A solution in this scenario is to enumerate all needed schemas in the Schema connection string parameter. For example, specify "schema=public,test;" instead of "schema=public;" in your connection string.
So we create a database, specified in the Database connection string parameter, and a schema(s), which is set in the Schema connection string option.
And when DDL for migration is generated, we already do not have access to the actual connection.
A solution in this scenario is to enumerate all needed schemas in the Schema connection string parameter. For example, specify "schema=public,test;" instead of "schema=public;" in your connection string.