I’m a noob w/ Linq-to-Entity. These are my database tables.
create table Jobs
( ID NUMBER PRIMARY KEY,
....
)
create table Responsibilities
( ID NUMBER PRIMARY KEY,
JobID NUMBER
....
)
The JobID column is a foreign key that references Jobs(ID).
Using these tables, in Visual Studio I automatically create the classes that allow me to interface to those tables. I then try to create Jobs and insert them into the database. I have triggers on every table to generate a unique ID for each table for the primary key. Below is a snippet of code that creates a Job.
using (Workflow.WorkflowEntities entity = new Workflow.WorkflowEntities(connectionString))
{
JOBS j = new JOBS();
entity.AddToJOBS(j);
entity.SaveChanges();
A problem that I’m having, is that when the Job is saved, I don’t get a primary key back for it. This is especially a problem when I want to create Responsibilities objects and add them to the Job and then save everything en masse. Its like it doesn’t populate the JobID field correctly in the Responsibilities object.
What is the correct way to do this? Any pointers are greatly appreciated,
mj
I found the answer. 3rd from the end post on this page.
https://forums.oracle.com/forums/thread.jspa?messageID=9904561
Apparently Visual Studio 2010 doesn’t save the StoreGeneratedPattern attribute in the XML correctly.
EDIT 1: I think Visual Studio 2010 service pack 1 fixes this.