Page 1 of 1

Schema omitted from Code First generated script

Posted: Tue 08 Aug 2017 11:51
by Globox
Hello!

We have a problem creating tables in a specific schema using Entity Framework 6.
The migration code from which the SQL script is generated looks like this:

Code: Select all

 CreateTable(
                "dbo.Users",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Type = c.Int(nullable: false, defaultValue: 1,
                            annotations: new Dictionary<string, AnnotationValues>
                            {
                                { 
                                    "EnumValues",
                                    new AnnotationValues(oldValue: null, newValue: "1,2,3,4,5,6")
                                },
                            }),
                        Timestamp = c.DateTimeOffset(nullable: false, precision: 7),
                        EntityTypeName = c.String(nullable: false, maxLength: 128),
                        EntityId = c.Long(nullable: false),
                        UserId = c.Int(),
                        OriginalPropertyValues = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Users", t => t.UserId)
                .Index(t => t.UserId);
However, after running Update-database, the script sent to the database looks like this:

Code: Select all

-- Script was generated by Devart dotConnect for Oracle, Version 9.4.314
-- Product home page: http://www.devart.com/dotconnect/oracle
-- Database version: Oracle 12.2.0.1
-- Script date 2017.08.08. 13:48:28

CREATE TABLE "Users" ( 
  "Id" NUMBER(19) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL,
  "Type" NUMBER(10) DEFAULT 1 NOT NULL,
  "Timestamp" TIMESTAMP(7) WITH TIME ZONE NOT NULL,
  "EntityTypeName" NVARCHAR2(128) NOT NULL,
  "EntityId" NUMBER(19) NOT NULL,
  "UserId" NUMBER(10) NULL,
  "OriginalPropertyValues" NCLOB NULL,
  PRIMARY KEY ("Id")
)
Note the schema name 'dbo' missing this time, thus it creates the table for the currently logged in user (which has all the privileges to create objects in another schema).

Re: Schema omitted from Code First generated script

Posted: Thu 10 Aug 2017 10:45
by Shalex
Please set config.Workarounds.IgnoreDboSchemaName=false;

EITHER in a static constructor of the context:

Code: Select all

    var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
    config.Workarounds.IgnoreDboSchemaName=false;
OR in *.config:

Code: Select all

  <configSections>
  <section name="Devart.Data.Oracle.Entity"   type="Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfigurationSection,   Devart.Data.Oracle.Entity.EF6, Version=9.4.236.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
  </configSections>  
...
  <Devart.Data.Oracle.Entity xmlns="http://devart.com/schemas/Devart.Data.Oracle.Entity/1.0">
    <Workarounds IgnoreDboSchemaName="false" />
  </Devart.Data.Oracle.Entity>
For more information, refer to https://www.devart.com/dotconnect/oracl ... tions.html.