Page 1 of 1

EntityFramework with Sequence

Posted: Wed 08 Dec 2010 22:05
by JoeRuspante
Hi everybody.

I'm using the new version of the DotConnect (6.0.58)
I have a simple table (MyTable) with two fields:

ID -> Integer (sequence)
NAME -> String

If I use the EntityFramework and I use this code:

Code: Select all

Context ctx = new Context();

MyTable t = new MyTable();
t.NAME = "Test";

ctx.MyTables.Add(t);
ctx.SaveChanges();

Console.Writeline(t.ID);


After the "SaveChanges", the ID is still 0 (zero). Why doesn't EntityFramework load it?
If I look into the DB, the new value is saved and the ID is se correclty (the first time, on the Oracle DB there is a single row with ID equals 1 and NAME is Test.

Posted: Thu 09 Dec 2010 14:58
by AndreyR
Please make sure that you have set the StoredGeneratedPattern attribute in the Store part of the model to "Identity".
This issue was already discussed here.

Posted: Mon 13 Dec 2010 14:59
by dimsavva
Hi,

I have the exact same problem.
I have made sure that StoredGeneratedPattern is set to identity.
The value for the ID does get generated in the db, but still returns 0;

I am using VS 2010, EF4. I have also tried this using the devart entity developer, same issue.

Really stuck here, please help.

Posted: Mon 13 Dec 2010 15:33
by AndreyR
Please make sure that the StoreGeneratedPattern attribute is set in the Store part of the model. If it is in place, please send us (support * devart * com, subject "EF Identity") a small test project (or at least the model file) reproducing the error.

Hi.

Posted: Wed 19 Jan 2011 23:15
by JoeRuspante
I sent to you the example about a mounth ago, but I don't see any reply.
There are any news?

(I Re-send the same email today, so you can look at it)

Posted: Thu 20 Jan 2011 16:48
by AndreyR
I have set the StoreGeneratedPattern attribute in the Store part of the model and your project worked correctly.
I have sent the corrected project back.