I have Oracle DB that has multiple Tables (Three of them have ID Column with ALWAYS GENERATED IDENTITY) that is required to be connected to Windows Form.
BREAKDOWN Table
CREATE TABLE "BREAKDOWN"
("EQUIPMENTID" NCHAR(8) NOT NULL ENABLE,
"FROMTIME" TIMESTAMP (4),
"TOTIME" TIMESTAMP (4),
"WORKORDER" NUMBER(10,0) NOT NULL ENABLE,
"BDNREASON" NCHAR(10),
"BDNTIME" INTERVAL DAY (2) TO SECOND (6) GENERATED ALWAYS AS (("TOTIME"-"FROMTIME")DAY(9) TO SECOND(4)) VIRTUAL ,
"BREAKDOWNID" NUMBER(10,0) GENERATED ALWAYS AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOT NULL ENABLE,
CONSTRAINT "BREAKDOWN_PK" PRIMARY KEY ("BREAKDOWNID") )
BREAKDOWN Generated Class
public partial class BREAKDOWN
{
public string EQUIPMENTID { get; set; }
public Nullable<System.DateTime> FROMTIME { get; set; }
public Nullable<System.DateTime> TOTIME { get; set; }
public int WORKORDER { get; set; }
public string BDNREASON { get; set; }
public int BREAKDOWNID { get; set; }
public Nullable<decimal> BDNTIME { get; set; }
public virtual EQUIPMENT EQUIPMENT { get; set; }
public virtual WORKORDER WORKORDER1 { get; set; }
}
WORKORDER Table
CREATE TABLE "WORKORDER"
(
"WORKORDERTYPEID" NCHAR(3) NOT NULL ENABLE,
"WORKORDEREQUIPMENTID" NCHAR(8) NOT NULL ENABLE,
"WORKORDERREGISTERATIONDATE" TIMESTAMP (3) NOT NULL ENABLE,
"WORKORDERID" NUMBER(10,0) GENERATED ALWAYS AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE NOT NULL ENABLE,
CONSTRAINT "WORKORDER_PK" PRIMARY KEY ("WORKORDERID")
)
WORKORDER Generated Class
public partial class WORKORDER
{
public WORKORDER()
{
this.BREAKDOWNs = new HashSet<BREAKDOWN>();
}
public string WORKORDERTYPEID { get; set; }
public string WORKORDEREQUIPMENTID { get; set; }
public System.DateTime WORKORDERREGISTERATIONDATE { get; set; }
public int WORKORDERID { get; set; }
}
IDENTITY is working properly for the three tables if I tried to INSERT using ORACLE SQL Developer
whileas if I tried to insert using the Windows form View using (Add() Function) it raises the mentioned Error:
System.Data.Entity.Infrastructure.DbUpdateException: 'An error occurred while updating the entries. See the inner exception for details.' UpdateException: An error occurred while updating the entries. See the inner exception for details. OracleException: ORA-54013: INSERT operation disallowed on virtual columns ORA-06512: at line 4
This occurs for only BREAKDOWN
BREAKDOWN newBDN = new BREAKDOWN();
newBDN.WORKORDER = workOrder.WORKORDERID;
newBDN.EQUIPMENTID = workOrder.WORKORDEREQUIPMENTID;
newBDN.FROMTIME = bdnFromDateTimePicker.Value;
home.dbContext.BREAKDOWNs.Add(newBDN);
home.dbContext.SaveChanges();
while WORKORDER table is operating properly!!
WORKORDER newWorkOrder= new WORKORDER ();
newWorkOrder.EQUIPMENT = (EQUIPMENT) equipmentBindingSource.DataSource;
newWorkOrder.WORKORDERREGISTERATIONDATE = regsiterationDatePicker.Value;
newWorkOrder.WORKORDERTYPE = (WORKORDERTYPE)workTypeTextBox.SelectedItem;
home.dbContext.WORKORDERs.Add(newWorkOrder);
home.dbContext.SaveChanges();
I have assured that following:
- Columns are all IDENTITY with the required ISEQ.
- Data types for all the Columns are identical in both DBTables and Entites.
- ORACLE is calculating IDENTITY Property properly (Manual Inserting using ORACLE SQL Developer)