I have 2 tables Jobs and Schedule
Jobs
JobId - int,PK, Identity
ScheduleId - int, FK
Title - varchar
Description - varchar
Schedules
ScheduleId - int,PK, Identity
Name - varchar
There is a relationship one to many with cascade on delete.
When I create Entity model, the generated Jobs model removes the ScheduleId field.
The Problem is that I can't Insert new Job with specified ScheduleId!
Job job = new Job();
job.title= "blabla";
job.description="xyz";
job.scheduleId=1// can't have this!
if (job.EntityState == EntityState.Detached)
{
myContext.AddToJobs(job);
}
myContext.SaveChanges();
Note: I have a row in Schedules table with scheduleId=1.