How succesfully set a Database Relationship in .net?
Hello guys!
How is it going? I'm developing a simple App for a College's programming subject. And I'm trying to establish a correct database Relationship, but When I tried to make a GET request, Swagger throws:
This is the models data with their default relationship:
I tried to set a one-to-Many relationship with Teacher-Subject because a teacher can teach many subjects, while a Subject merely have a single teacher. I set the Teacher's dni as foreign and primary key, as you can see below
In the second relationship, I settled Many-Many relationship to Student-Subject, because a Student can be in many subjects and Subject containe many students. I set the Student's dni as a primary and foreign key. And I settled the Subject's Id as a primary key.
However, when I tested in Swagger, it return me the following error:
If anyone could help me, I'd be really grateful.
How is it going? I'm developing a simple App for a College's programming subject. And I'm trying to establish a correct database Relationship, but When I tried to make a GET request, Swagger throws:
The [ForeignKey] attribute for the navigation 'Students' cannot be specified on the entity type 'Subject' since it represents a one-to-many relationship. Move the [ForeignKey] attribute to a property on 'Student'. This is the models data with their default relationship:
I tried to set a one-to-Many relationship with Teacher-Subject because a teacher can teach many subjects, while a Subject merely have a single teacher. I set the Teacher's dni as foreign and primary key, as you can see below
In the second relationship, I settled Many-Many relationship to Student-Subject, because a Student can be in many subjects and Subject containe many students. I set the Student's dni as a primary and foreign key. And I settled the Subject's Id as a primary key.
However, when I tested in Swagger, it return me the following error:
If anyone could help me, I'd be really grateful.


