entity framework - EntityFramework Many to Many get link -


i have following models:

public class step {     [key]     public int id { get; set; }     [required]     public string name { get; set; }      public workflow workflow { get; set; }     public list<stepoption> options{ get; set; }      internal stepdto todto() {         return new stepdto {             id = this.id,              name = this.name,         };     } } 

and

public class stepoption {     [key]     public int id { get; set; }     [required]     public string name { get; set; }      public list<step> steps { get; set; } } 

so can see there many many relationship between steps , stepoptions.

when run database seeder, following seed:

var workflow = new workflow {id = 1,  name = "some workflow" };  context.workflows.addorupdate(w => w.name, workflow);  var accept = new stepoption { id = 1 ,name = "accept" }; var reject = new stepoption {id = 2, name = "reject" }; var advies = new stepoption {id = 3, name = "advies" }; context.stepoptions.addorupdate(x => x.name, accept, reject, advies);  var step1 = new step {id = 1, name = "start", workflow = workflow, options = new list<stepoption> { accept } }; var step2 = new step { id = 2, name = "validatie bouwheer", workflow = workflow, options = new list<stepoption> { accept, reject } }; var step3 = new step { id = 3, name = "controlling1", workflow = workflow }; var step4 = new step { id = 4, name = "adviezen", workflow = workflow }; var step5 = new step {id = 5, name = "ondersteuning", workflow = workflow }; var step6 = new step { id = 6, name = "directie", workflow = workflow }; var step7 = new step { id = 7, name = "controlling2", workflow = workflow }; var step8 = new step { id = 8, name = "reject", workflow = workflow }; var step9 = new step { id = 9, name = "finish", workflow = workflow }; context.steps.addorupdate(s => s.id,     step1, step2, step3, step4, step5, step6, step7, step8, step9 ); 

there 3 columns in db:

  1. steps
  2. stepoptions
  3. stepoptionssteps

but wondering how access stepoptions steps object, it's null, although in db stepoptionssteps linked correctly


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -