c# - Cycles or multiple cascade paths -


i have following datamodel , associated model classes. have been removing dependencies right, keep on getting error.

datamodel

class diagram

i can't find out why there cascading path in model. afraid not able reduce dependencies.

model classes

public class dataformat {     public int dataformatid { get; set; }     [display (name = "data format name")]     [remote("duplicateformatname", "dataformats", httpmethod = "post", errormessage = "data format name exists")]     public string formatname { get; set; }     [display (name = "data format type")]     public string formattype { get; set; }     [display (name = "precision digits")]     public string precisiondigits { get; set; }     [display (name = "scaling digits")]     public string scalingdigits { get; set; }     [display (name = "description in german")]     public string descriptionde { get; set; }     [display (name = "description in english")]     public string descriptionen { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     public string createdby { get; set;}     public string modifiedby { get; set; }      public virtual icollection<tcset> tcsets { get; set; } }  public class lsystem {     public int lsystemid { get; set; }     [display (name = "system name") ]     [remote("duplicatesystemname", "lsystems", httpmethod = "post", errormessage = "system name exists")]     public string lsystemname { get; set; }     [display (name = "material number")]     public string materialnumber { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     public string createdby { get; set; }     public string modifiedby { get; set; }     [display(name = "description in english")]     public string descriptionen { get; set; }     [display(name = "description in german")]     public string descriptionde { get; set; }      public int lsystemfamilyid { get; set; }      public virtual lsystemfamily lsystemfamily { get; set; }     public virtual icollection<option> options { get; set; } }  public class lsystemfamily {     public int lsystemfamilyid { get; set; }     [display (name = "family name")]     [remote("duplicatefamilyname","lsystemfamilies",httpmethod = "post",errormessage= "system family name exists")]     public string familyname { get; set; }     public int lsystemcount { get; set; }     [display ( name = "description in english")]     public string descriptionen { get; set; }     [display (name = "description in german")]     public string descriptionde { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     public string createdby { get; set; }     public string modifiedby { get; set; }      public virtual icollection<lsystem> lsystems { get; set; } }  public class option {     public int optionid { get; set;}     [display (name = "option type")]     public string optionname { get; set; }     [display (name ="description in english")]     public string descriptionen { get; set; }     [display(name = "description in german")]     public string descriptionde { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     public string createdby { get; set; }     public string modifiedby { get; set; }      public int technicalcharacteristicid { get; set; }     public int lsystemid { get; set; }      public virtual icollection<optionvalue> optionvalues { get; set; }     public virtual technicalcharacteristic technicalcharacteristic { get; set; }     public virtual lsystem lsystem { get; set; }    // public virtual icollection< setvalue> setvalue { get; set; } }  public class optionvalue {     public int optionvalueid { get; set; }     [display(name = "option value")]     public string optionval { get; set; }      public int optionid { get; set; }    // public int setvalueid { get; set; }      public virtual option option { get; set; }     public virtual icollection< setvalue> setvalue { get; set; } }  public class setvalue {     public int setvalueid { get; set; }     [display(name = "value")]     public string value { get; set; }     [display(name="internal")]     public bool status { get; set; }      //public int lsystemid { get; set; }     //public int optionid { get; set; }     public int tcsetid { get; set; }     public int optionvalueid { get; set; }      //public virtual lsystem lsystem { get; set; }     //public virtual option option { get; set; }     public virtual optionvalue optionvalue { get; set; }     public virtual tcset tcset { get; set; }  }  public class tcset {     public int tcsetid { get; set; }     [display (name = "technical characteristic property name")]     public string setname { get; set; }     [display(name = "physicalunit")]     public string physicalunit { get; set; }     [display (name = "data usage")]     public datausage datausage { get; set; }     [display (name = "data status")]     public datastatus datastatus { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     [display (name = "description in german")]     public string descriptionde { get; set; }     [display (name = "description in english")]     public string descriptionen { get; set; }     public string createdby { get; set; }     public string modifiedby { get; set; }      public int technicalcharacteristicid { get; set; }     public int dataformatid { get; set; }      public virtual icollection<setvalue> setvalues { get; set; }     public virtual dataformat dataformat { get; set; }     public virtual technicalcharacteristic technicalcharacteristic { get; set; } }  public class technicalcharacteristic {     public int technicalcharacteristicid { get; set; }     [display (name = "technical characteristic name")]     public string tcname { get; set; }     [display (name = "description in english")]     public string descriptionen { get; set; }     [display (name = "description in german")]     public string descriptionde { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     public string createdby { get; set; }     public string modifiedby { get; set; }      public virtual icollection<tcset> tcsets { get; set; }     //public virtual icollection<option> options { get; set; } } 

now error between tables options , technicalcharacteristics. had error previosly lsystem , setval & options.

what can workaround task right? have not tried fluent apis.

here way can same , have technicalchareristic required. did last week 1 of own models. sorry toook long come reply. (do same other files.)

in context file override following method...

  protected override void onmodelcreating(dbmodelbuilder modelbuilder)     {         modelbuilder.entity<option>()             .hasrequired(x => x.technicalcharacteristic)             .withmany(y => y.options)             .hasforeignkey(a => a.technicalcharacteristicid)             .willcascadeondelete(false);          base.onmodelcreating(modelbuilder);     } 

where models are...

public class option {     public int optionid { get; set; }     [display(name = "option type")]     public string optionname { get; set; }     [display(name = "description in english")]     public string descriptionen { get; set; }     [display(name = "description in german")]     public string descriptionde { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     public string createdby { get; set; }     public string modifiedby { get; set; }      public int lsystemid { get; set; }      public virtual icollection<optionvalue> optionvalues { get; set; }      public int technicalcharacteristicid { get; set; }     public virtual technicalcharacteristic technicalcharacteristic { get; set; }     public virtual lsystem lsystem { get; set; }     // public virtual icollection< setvalue> setvalue { get; set; }      datetime d = new datetime(); }   public class technicalcharacteristic {     public int technicalcharacteristicid { get; set; }     [display(name = "technical characteristic name")]     public string tcname { get; set; }     [display(name = "description in english")]     public string descriptionen { get; set; }     [display(name = "description in german")]     public string descriptionde { get; set; }     public datetime createdon { get; set; }     public datetime modifiedon { get; set; }     public string createdby { get; set; }     public string modifiedby { get; set; }      public virtual icollection<tcset> tcsets { get; set; }     public virtual icollection<option> options { get; set; }  } 

i hope helps.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -