How to automatically generate identity for an Oracle database through Entity framework?

前端 未结 5 1725
自闭症患者
自闭症患者 2020-12-15 08:50

I\'m using Oracle provider for Entity framework (beta), and I\'m facing a problem.

Our tables have Id columns, which are set to be Identity in StoreGeneratedPattern.

5条回答
  •  别那么骄傲
    2020-12-15 09:33

    Instead of remember all of this SQL, you could easily do by using Mig# like this:

            var schema = new DbSchema(ConnectionString, DbPlatform.Oracle12c);
            schema.Alter(db => db.CreateTable("TableName")
                .WithPrimaryKeyColumn("Id", DbType.Int32).AsIdentity()
                ...);
    

    In this example, the Id column will have the required trigger and sequence generated by Mig# automatically.

提交回复
热议问题