you are right i have a circular reference but it's normal because my CDM is like that : enter image description here
i will have 2 methods GetPublishers and GetBooks. When i will have the result for GetPublishers, i wanted to have this
[
{
"PublisherId": 1,
"PublisherName": "NamePublisher1",
"BookPublisher": [
{
"BookPublisherId": 1,
"BookId": 1,
"PublisherId": 1,
"Book": {
"BookId": 1,
"BookName": "TEST1",
}
},
{
"BookPublisherId": 2,
"BookId": 2,
"PublisherId": 1,
"Book": {
"BookId": 2,
"BookName": "TEST2",
}
},
]
}
]
and when i want the result of GetBooks, the result have to be this
[
{
"BookId": 1,
"BookName": "TEST1",
"BookPublisher": [
{
"BookPublisherId": 1,
"BookId": 1,
"PublisherId": 1,
"Publisher": {
"PublisherId": 1,
"PublisherName": "NamePublisher1",
}
}
]
},
{
"BookId": 2,
"BookName": "TEST2",
"BookPublisher": [
{
"BookPublisherId": 2,
"BookId": 2,
"PublisherId": 1,
"Publisher": {
"PublisherId": 1,
"PublisherName": "NamePublisher1",
}
}
]
}
]
So my class define before are ok and on the methode "OnModelCreating" i don't put relation.