Question

I wrote a simple test program which will access the default HR model on an Oracle Express in direct mode using DevArt dotConnect for Oracle v. 6.8.0.350:

using (var ctx = new HREntities())
{
    var locNew = new LOCATION();
    locNew.CITY = "Magdeburg";
    ctx.LOCATIONs.AddObject(locNew);
    ctx.SaveChanges();
    // will output 0; in database ID is generated
    Console.WriteLine(locNew.LOCATIONID);
}

As you can see I'm doing an insert into the LOCATION table. Here I added a trigger:

create or replace
trigger TRG_LOCATION_INS  
   before insert on "HR"."LOCATIONS" 
   for each row 
begin  
   if inserting then 
      select LOCATIONS_SEQ.nextval into :NEW."LOCATION_ID" from dual;       
   end if; 
end;

Last step was setting StoreGeneratedPattern in my model to Identity (yes, I checked if it is written to the XML).

If I run the test-app, the record is created and it has got a valid new LocationID. But in EF the new ID will not arrive.

Why isn't it recognizing the generated ID? If yes, what does that mean: DevArt Blog

EDIT: I tested it in different scenarios now:

  1. devArt EntityModel in Direct Mode
  2. devArt EntityModel with OracleClient
  3. ADO.NET EntityModel with OracleClient

The result is the same. No DSID is returned on SaveChanged. As another result, if I write

ctx.Refresh(RefreshMode.ClientWins, log);

an InvalidOperationException will raise saying, that there is now entity with key '0' which is correct but not helpful :-(.

Was it helpful?

Solution

If you look in the .edmx file you see there is a conceptual schema and a storage schema defined. If you change the StoreGeneratedPattern in the designer, it will only change it in the conceptual schema, but not in the storage schema, which is really necessary.

The StoreGeneratedPattern is in the designer for model-first development, if you generate the database from the model, else it doesn't have effect. So you have to manually insert the attribute in the storage schema.

OTHER TIPS

After a few tests I took a look at the XML of my edml again and I saw, that StoreGeneratedPattern did not arrive at the XML. I don't know, what happened because in my initial post I wrote, that I checked the XML. The first time I did this, the Attribute was there. However, just for those of you interested in the solution look here: Solution in other thread

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top