title: EntityFramework Insert into Oracle table with a sequence as PK
body: <p>I'm doing an insert with EF like this:</p>
  
  <pre><code>        using (Entities1 ctx = new Entities1())
          {
              ADDRESS_RESOLVER addrRes = new ADDRESS_RESOLVER();
              addrRes.ZIP_VEGA = addr.ZipVega;
  
              ctx.ADDRESS_RESOLVER.Add(addrRes);
              ctx.SaveChanges();
          }
  </code></pre>
  
  <p>The table ADDRESS_RESOLVER has a primary key ID with a sequence associated. The trigger look like this:</p>
  
  <pre><code>create or replace 
  trigger SEQ_ADDRESS_RESOLVER_ID  
     before insert on "MY_DB"."ADDRESS_RESOLVER" 
     for each row 
  begin  
     if inserting then 
        if :NEW."ID" is null then 
           select SEQ_ADDRESS_RESOLVER.nextval into :NEW."ID" from dual; 
        end if; 
     end if; 
  end;
  </code></pre>
  
  <p>The problem is my EF object addrRes has the ID settet do 0 and I cannot set it to null because it's a PK so when I try to do the insert the trigger doesn't work. My solution is changing the "if" in the trigger to "0" instead of "null" but I'm not sure if it is the right solution. Is there a smarter way to do this?</p>