Schema omitted from Code First generated script
Posted: Tue 08 Aug 2017 11:51
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:
However, after running Update-database, the script sent to the database looks like this:
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).
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);
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")
)