asp.net - Unable to determine a valid ordering error when using self referencing -
i have schema :
category
entity have reference via parentcategoryid
field.parentcategoryid
field nullable.i use database first way.this generated code entity
:
public partial class category { public category() { this.category1 = new hashset<category>(); this.news = new hashset<news>(); } public int categoryid { get; set; } public string name { get; set; } public nullable<int> parentcategoryid { get; set; } public virtual icollection<category> category1 { get; set; } public virtual category category2 { get; set; } public virtual icollection<news> news { get; set; } }
when insert category parentcategoryid
field nullable,every thing ok,but when select value parentcategoryid
i exception:
unable determine valid ordering dependent operations. dependencies may exist due foreign key constraints, model requirements, or store-generated values
i had category pk=0 , when selected parent got mentioned error.after removing category problem resolved.
Comments
Post a Comment