Entity Framework Ignore Schema

ef-code-first, entity-framework, entity-framework-6, odp.net, oracle

Solution

FrankO's answer is correct in that you can specify the default schema using the Fluent API.

In addition, this same method, in my experience, can be utilized to remove the default schema, allowing Oracle to resolve the schema in the case that it is specified on the connect string or if your companies policy is to access all tables through a public synonym.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.HasDefaultSchema(string.Empty);
}

This would produce SQL containing `FROM "MY_TABLE"` instead of `FROM "dbo"."MY_TABLE"`

I'm using:

- EntityFramework 6.1.3

- Oracle.ManagedDataAccess 12.1.2400

- Oracle.ManagedDataAccess.EntityFramework 12.1.2400

Problem

I am using Entity Framework 6 Code First to connect to an oracle database. EF is using "dbo" as the schema. I would rather not specify the schema, but rather let Oracle resolve the schema from the connection string. Is there a way to omit "dbo" or any schema from the queries? Example Given: Instead of "select * from dbo.table" I would like to see "select * from table". Currently, I am parsing the connection string for the userId and using that as the schema, but I'd prefer to not use this technique.

Original source