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

前端 未结 5 1691
自闭症患者
自闭症患者 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:26

    Another option would be:

    Create a sequence the way Alextansc described. Create a stored procedure that uses MySequence.nextval as it's primary key.

    Map 'insert' for this model to your stored procedure and it works!

    I've tested this using database first approach.

    Using database first mapping to a stored procedure is pretty simple. Go to your edmx file and right click the model you want to map to a stored procedure. Click "stored procedure mappings." The dialog at the bottom of the page gives you three drop down menus for mapping insert, update, and delete to stored procedures.

提交回复
热议问题