KoolKabin
KoolKabin

Reputation: 17683

How to create table with identity column using entity framework core code first migration to oracle db?

This is the code generated by ef core after we do add-migration

 migrationBuilder.CreateTable(
     name: "Provinces",
     ////schema: "some schema",
     columns: table => new
     {
         Id = table.Column<int>(type: "NUMBER(10)", nullable: false)
             .Annotation("Oracle:Identity", "START WITH 1 INCREMENT BY 1"),
         Title = table.Column<string>(type: "NVARCHAR2(255)", maxLength: 255, nullable: false),
         Code = table.Column<string>(type: "NVARCHAR2(10)", maxLength: 10, nullable: false),
         Deleted = table.Column<bool>(type: "NUMBER(1)", nullable: false)
     },
     constraints: table =>
     {
         table.PrimaryKey("PK_Provinces", x => x.Id);
     });

I expected it to work against oracle db 11

but its saying error msg like: missing always keyword for identity column creation

Edit

Instead of doing it manually i solved it with SQLCompatibility Version Set in DBConfigure

Upvotes: 0

Views: 75

Answers (1)

MT0
MT0

Reputation: 168505

I expected it to work against oracle db 11

Oracle 11g does not support IDENTITY columns; they were introduced in Oracle 12.

If you are using Oracle 11g then you will need to use a trigger and a sequence to manage the identity.

Upvotes: 1

Related Questions