views:

104

answers:

2

im working on a LINQ to Entities project for school, i am working with a db2 database that generates key values through a generated sequence eg. INSERT INTO STUDENT VALUES(NEXT VALUE FOR STUDENT_NUM, 'Raphael', 'Joasia'); is the there an equivalent to the NEXT VALUE operator in LINQ to Entities that will do the same or will i need to change how my database operates in regards to generating keys? i do use this sequence for generating values on several foreign key tables if there is a way to do this it would be a huge help

A: 

A related question was asked here. http://stackoverflow.com/questions/120755/ado-net-entity-framework-and-identity-columns Short answer is entity framework plays well with int keys but not GUID keys. Details are in the answers to the previously asked question. Also there will not be an ID parameter for creating the new object.

awright18
would you say that this could be worked around by using a stored procedure for the insert on the tables that require the sequence values or would this be considered a dirty way to code (would like to keep as standards based as possible as this is going to be used as a demo for ASP.net MVC
Chris McGrath
A: 

Unless you can generate the key itself you will need to use a stored procedure like you said. The first release of Entity Framework doesn't handle edge case scenarios very well, even if this doesn't seem like much of an edge case...

Greg Roberts
ya looks like stored procs it is i havent been able to find anything on it so far
Chris McGrath