How to get added entity Id? Entity Framework 6 Oracle 11 - oracle

I am using EF6 database first, against Oracle 11. the tables ids are generated by trigger using a sequence in the database.
When I add an entity through EF, the ID is not retrieved back as expected, any clue what is wrong?
using (var Context = new Context())
{
Context.DATASETS.Add(datasetToAdd);
Context.SaveChanges();
}
datasetToAdd.ID is not populated.

Ensure that the database column is IDENTITY, and that StoreGeneratedPattern is set to Identity in EDMX.

Related

ResultSet TYPE_SCROLL_SENSITIVE equal feature in ado.net

I am new to ado.net, i come up with a question, in java we have a option to show the update the result set continuously with TYPE_SCROLL_SENSITIVE is there any such functionality exists in ado.net to update the data table when underlying table is updated?

Data insertion issue using cakephp 3.2 to oracle 11g tables

I am just trying to build a simple crud application using cakephp and oracle. But when i am trying to add a new data from my add.ctp its return with this error. can anyone help. Errors are below.
ORA-01400: cannot insert NULL into ("HR"."EMP"."EMP_ID")
CakeDC\OracleDriver\Database\OCI8\OCI8Exception
BTW here 'EMP_ID' is primary key of 'EMP' table and i have also created sequence.
You should try to create all tables strctures using cakephp migrations.
The reason of that - datasource when create table dditionally create not only sequence, but also a triger, to fill id field. Also driver written in way to follow cakephp table field naming conventions. So you can just take EMP schema and get everything work.
Options are: create all tables using migrations from cakephp side, or write trigger that will fill id fields manual on oracle side.

Hibernate `assigned` strategy returns 0 with sequence and trigger

I've Table uses Trigger and sequence to set its PK column.
The Hibernate mapping strategy for its Pk is assigned..
This yields in session.save(obj) returns object with id=0
How to make it returns the correct assigned PK value.
session.getIdentifier() doesn't work!
assigned means: Nobody generates the ID, the ID is set explicitely in the entity before persisting it.
What you want to do is impossible. Hibernate would have to insert an entity without knowing its ID, then the database would generate the ID, and Hibernate would have to reload the entity from the database to know its ID. But how would it reload the entity without knowing its ID?
The native generator does the same thing, and it works because the database provides a getLastGeneratedId() method which allows getting the IOD that the database has generated. But you can't do that with Oracle and a trigger.
Remove the trigger from the database, use the sequence generator, and everything will be fine.

Identity_insert off in Entity Framework

I am using Entity Framework for CRUD operations. When I tried to insert data in a table which has an identity column, it throws an exception
Identity_Insert is set to off
I don't know how to turn that on. Do I need to reconfigure entity data model for that?
Sounds like the EF is including an explicit value for the PK in the INSERT. It should not do this. Make sure StoreGeneratedPattern is set to identity on the PK in the SSDL. This article might help.

Maximum number of columns in a LINQ to SQL object?

I have 62 columns in a table under SQL 2005 and LINQ to SQL doesn't handle the updates though the reading would work just fine, I tried re-adding the table to the model, created a new data model but nothing worked, I'm guessing I've hit the maximum number of columns limit on an object, can anyone explain that ?
I suspect there is some issue with an identity or timestamp column (something autogenerated on the SQL server). Make sure that any column that is autogenerated is marked that way in the model. You might also want to look at how it is handling concurrency. If you have triggers that update any values on the row after it is updated (changing values) and it is checking all columns on updates, this would cause the update to fail. Typically I create my tables with a timestamp column -- LINQ2SQL picks this up when I generate the model and uses it alone for concurrency.
Solved, either one of the following two
-I'm using a UniqueIdentifier column that was not set as Primary key
-Set Unique ID primary key, checked the properties of the same column in Server Explorer and it was still not showing as Primary key, refreshed the connection,dropped the same table on the model and voila.
So I assume I made a change to my model some time before, deleted the table from the model and added the same from the Server explorer without refreshing the connection and it never used to work.
Question is, does VS Server Explorer maintain it's own table schema and requires connection refresh everytime a change is made in the database ?
There is no limit to the number of columns LINQ to SQL will handle.
Have you got other tables updating successfully?
What else is different about how you are accessing the table content?

Resources