Hi all i have model sections
like this below
public class Sections
{
public int SectionId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Requests Requests { get; set; }
}
the structure of the data for sections model like this below
sectionId Name description
1 code1 code 1
2 code2 code 2
i have one more model Requests
and the model looks like this below
public class Requests
{
public int RequestId { get; set; }
public string Description { get; set; }
public int SectionId { get; set; }
public Sections sections { get; set; }
}
and the structure of sample data for Requests model like this below
RequestId Description SectionId
1 test1 1
2 test2 1
3 test1 2
4 test2 2
with this structure of model data i am mapping these two models below
modelBuilder.Entity<Requests>()
.HasOne(a => a.sections)
.WithOne(o => o.Requests); //not sure if this is correct way to map these two models with one-to-many mapping as listed in requests model
is that above mentioned mapping is correct way to achieve the same and I am using Entity framework core code first approach.
if i don't use above mapping i am getting this error:
The child/dependent side could not be determined for the one-to-one relationship between
Requests.sections
andSections.Requests
.
Could any one please let me know if there is any other way to map those two models