{"id":23387128,"url":"https://github.com/manusoft/ef-core-relation-demo","last_synced_at":"2025-06-29T18:03:35.442Z","repository":{"id":268344981,"uuid":"904020935","full_name":"manusoft/ef-core-relation-demo","owner":"manusoft","description":"EFCore relations demo in ASP.Net Web API with dotnet.9","archived":false,"fork":false,"pushed_at":"2024-12-16T09:01:19.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T12:47:52.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manusoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-16T05:17:39.000Z","updated_at":"2024-12-16T09:01:23.000Z","dependencies_parsed_at":"2024-12-16T07:40:01.531Z","dependency_job_id":"eee2e1f7-9887-4646-a4cc-8e43cda50380","html_url":"https://github.com/manusoft/ef-core-relation-demo","commit_stats":null,"previous_names":["manusoft/ef-core-relation-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/manusoft/ef-core-relation-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manusoft%2Fef-core-relation-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manusoft%2Fef-core-relation-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manusoft%2Fef-core-relation-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manusoft%2Fef-core-relation-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manusoft","download_url":"https://codeload.github.com/manusoft/ef-core-relation-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manusoft%2Fef-core-relation-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262642961,"owners_count":23341816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-22T01:14:40.969Z","updated_at":"2025-06-29T18:03:35.390Z","avatar_url":"https://github.com/manusoft.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EF-Core-Relationships-Demo\n## 1. One-To-One\n### Models\n``` csharp\npublic class User\n{\n    public int Id { get; set; }\n    public string Name { get; set; } = null!;\n    public Profile? Profile { get; set; }\n}\n\npublic class Profile\n{\n    public int Id { get; set; }\n    public string Bio { get; set; } = null!;\n\n    public int UserId { get; set; }\n    public User? User { get; set; }\n}\n```\nTable structure for the provided classes, based on a relational database schema:\n\n### Table: `Users`\n| **Column Name** | **Data Type** | **Nullable** | **Description**          |\n|------------------|---------------|--------------|--------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the user.|\n| `Name`          | `string`      | `NO`         | Name of the user.        |\n\n### Table: `Profiles`\n| **Column Name** | **Data Type** | **Nullable** | **Description**          |\n|------------------|---------------|--------------|--------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the profile.|\n| `Bio`           | `string`      | `NO`         | Biography of the user.   |\n| `UserId`        | `int`         | `NO`         | Foreign key referencing `Users.Id`.|\n\n### Relationships\n1. **One-to-One Relationship**:  \n   - A `User` can have one `Profile`.\n   - A `Profile` must reference one `User` via `UserId`.\n2. **Foreign Key Constraint**:\n   - `Profiles.UserId` is a foreign key referencing `Users.Id`.\n\n### Add User Method 1\n``` json\n{\n  \"name\": \"John Wick\"\n}\n```\n### Add User Method 2 (with Profile)\n``` json\n{\n  \"name\": \"James Bond\",\n  \"profile\": {\n    \"bio\": \"An intelligent agent of England.\"    \n  }\n}\n```\n### Add Profile\n``` json\n{\n  \"bio\": \"A danagerous man in America.\",\n  \"userid\": 1\n}\n```\n### Get Users\n``` json\n[\n  {\n    \"id\": 1,\n    \"name\": \"John Wick\",\n    \"profile\": {\n      \"id\": 2,\n      \"bio\": \"A danagerous man in America.\",\n      \"userId\": 1,\n      \"user\": null\n    }\n  },\n  {\n    \"id\": 2,\n    \"name\": \"James Bond\",\n    \"profile\": {\n      \"id\": 1,\n      \"bio\": \"An intelligent agent of England.\",\n      \"userId\": 2,\n      \"user\": null\n    }\n  }\n]\n```\n### Get Profile\n``` json\n[\n  {\n    \"id\": 1,\n    \"name\": \"John Wick\",\n    \"profile\": {\n      \"id\": 2,\n      \"bio\": \"A danagerous man in America.\",\n      \"userId\": 1,\n      \"user\": null\n    }\n  },\n  {\n    \"id\": 2,\n    \"name\": \"James Bond\",\n    \"profile\": {\n      \"id\": 1,\n      \"bio\": \"An intelligent agent of England.\",\n      \"userId\": 2,\n      \"user\": null\n    }\n  }\n]\n```\n\n## 2. One-To-Many\n### Models\n``` csharp\npublic class Blog\n{\n    public int Id { get; set; }\n    public string Title { get; set; } = null!;\n\n    public ICollection\u003cPost\u003e? Posts { get; set; }\n}\n\npublic class Post\n{\n    public int Id { get; set; }\n    public string Content { get; set; } = null!;\n\n    public int BlogId { get; set; }\n    public Blog? Blog { get; set; }\n}\n```\nTable structure for the provided classes, based on a relational database schema:\n\n### Table: `Blogs`\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the blog.  |\n| `Title`         | `string`      | `NO`         | Title of the blog.         |\n\n### Table: `Posts`\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the post.  |\n| `Content`       | `string`      | `NO`         | Content of the post.       |\n| `BlogId`        | `int`         | `NO`         | Foreign key referencing `Blogs.Id`. |\n\n### Relationships\n1. **One-to-Many Relationship**:\n   - A `Blog` can have multiple `Posts`.\n   - A `Post` belongs to one `Blog` via `BlogId`.\n2. **Foreign Key Constraint**:\n   - `Posts.BlogId` is a foreign key referencing `Blogs.Id`.\n\n### Add Blog Method 1\n``` json\n{\n  \"title\": \"Blog-1\"\n}\n```\n### Add Blog Method 2 (with Posts)\n``` json\n{\n  \"title\": \"Blog-2\",\n  \"posts\": [\n    {\n      \"content\": \"This is Blog-2 content-1\"\n    },\n    {\n      \"content\": \"This is blog-2 content-2\"\n    }\n  ]\n}\n```\n### Add Post\n``` json\n{\n  \"content\": \"This is Blog-1 content.\",\n  \"blogId\": 1\n}\n```\n### Get Blogs\n``` json\n[\n  {\n    \"id\": 1,\n    \"title\": \"Blog-1\",\n    \"posts\": [\n      {\n        \"id\": 1,\n        \"content\": \"This is Blog-1 content.\",\n        \"blogId\": 1,\n        \"blog\": null\n      },\n      {\n        \"id\": 2,\n        \"content\": \"This is Blog-1 content-2.\",\n        \"blogId\": 1,\n        \"blog\": null\n      },\n      {\n        \"id\": 3,\n        \"content\": \"This is Blog-1 content-3.\",\n        \"blogId\": 1,\n        \"blog\": null\n      }\n    ]\n  },\n  {\n    \"id\": 2,\n    \"title\": \"Blog-2\",\n    \"posts\": [\n      {\n        \"id\": 4,\n        \"content\": \"This is Blog-2 content-1\",\n        \"blogId\": 2,\n        \"blog\": null\n      },\n      {\n        \"id\": 5,\n        \"content\": \"This is blog-2 content-2\",\n        \"blogId\": 2,\n        \"blog\": null\n      }\n    ]\n  }\n]\n```\n### Get Posts\n``` json\n[\n  {\n    \"id\": 1,\n    \"content\": \"This is Blog-1 content.\",\n    \"blogId\": 1,\n    \"blog\": {\n      \"id\": 1,\n      \"title\": \"Blog-1\",\n      \"posts\": [\n        null,\n        {\n          \"id\": 2,\n          \"content\": \"This is Blog-1 content-2.\",\n          \"blogId\": 1,\n          \"blog\": null\n        },\n        {\n          \"id\": 3,\n          \"content\": \"This is Blog-1 content-3.\",\n          \"blogId\": 1,\n          \"blog\": null\n        }\n      ]\n    }\n  },\n  {\n    \"id\": 2,\n    \"content\": \"This is Blog-1 content-2.\",\n    \"blogId\": 1,\n    \"blog\": {\n      \"id\": 1,\n      \"title\": \"Blog-1\",\n      \"posts\": [\n        {\n          \"id\": 1,\n          \"content\": \"This is Blog-1 content.\",\n          \"blogId\": 1,\n          \"blog\": null\n        },\n        null,\n        {\n          \"id\": 3,\n          \"content\": \"This is Blog-1 content-3.\",\n          \"blogId\": 1,\n          \"blog\": null\n        }\n      ]\n    }\n  },\n  {\n    \"id\": 3,\n    \"content\": \"This is Blog-1 content-3.\",\n    \"blogId\": 1,\n    \"blog\": {\n      \"id\": 1,\n      \"title\": \"Blog-1\",\n      \"posts\": [\n        {\n          \"id\": 1,\n          \"content\": \"This is Blog-1 content.\",\n          \"blogId\": 1,\n          \"blog\": null\n        },\n        {\n          \"id\": 2,\n          \"content\": \"This is Blog-1 content-2.\",\n          \"blogId\": 1,\n          \"blog\": null\n        },\n        null\n      ]\n    }\n  },\n  {\n    \"id\": 4,\n    \"content\": \"This is Blog-2 content-1\",\n    \"blogId\": 2,\n    \"blog\": {\n      \"id\": 2,\n      \"title\": \"Blog-2\",\n      \"posts\": [\n        null,\n        {\n          \"id\": 5,\n          \"content\": \"This is blog-2 content-2\",\n          \"blogId\": 2,\n          \"blog\": null\n        }\n      ]\n    }\n  },\n  {\n    \"id\": 5,\n    \"content\": \"This is blog-2 content-2\",\n    \"blogId\": 2,\n    \"blog\": {\n      \"id\": 2,\n      \"title\": \"Blog-2\",\n      \"posts\": [\n        {\n          \"id\": 4,\n          \"content\": \"This is Blog-2 content-1\",\n          \"blogId\": 2,\n          \"blog\": null\n        },\n        null\n      ]\n    }\n  }\n]\n```\n\n## 3. Many-To-Many\n### Models\n``` csharp\npublic class Student\n{\n    public int Id { get; set; }\n    public string Name { get; set; } = null!;\n\n    public ICollection\u003cStudentCourse\u003e? StudentsCourses { get; set; }\n}\n\npublic class Course\n{\n    public int Id { get; set; }\n    public string Name { get; set; } = null!;\n\n    public ICollection\u003cStudentCourse\u003e? StudentsCourses { get; set; }\n}\n\npublic class StudentCourse\n{\n    public int Id { get; set; }\n\n    public int StudentId { get; set; }\n    public Student? Student { get; set; }\n\n    public int CourseId { get;set; }\n    public Course? Course { get; set; }\n}\n```\nTable structure for the provided classes, based on a relational database schema:\n\n### Table: `Students`\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the student. |\n| `Name`          | `string`      | `NO`         | Name of the student.        |\n\n### Table: `Courses`\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the course. |\n| `Name`          | `string`      | `NO`         | Name of the course.         |\n\n### Table: `StudentCourses`\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the Student-Course relation. |\n| `StudentId`     | `int`         | `NO`         | Foreign key referencing `Students.Id`. |\n| `CourseId`      | `int`         | `NO`         | Foreign key referencing `Courses.Id`.  |\n\n### Relationships\n1. **Many-to-Many Relationship**:\n   - A `Student` can enroll in multiple `Courses`.\n   - A `Course` can have multiple `Students` enrolled.\n   - This relationship is implemented through the `StudentCourses` join table.\n2. **Foreign Key Constraints**:\n   - `StudentCourses.StudentId` is a foreign key referencing `Students.Id`.\n   - `StudentCourses.CourseId` is a foreign key referencing `Courses.Id`.\n\n### Add Student\n``` json\n{\n  \"name\": \"Student-1\"\n}\n```\n### Add Course\n``` json\n{\n  \"name\": \"BA\"\n}\n```\n### Add StudentCourse\n``` json\n{\n  \"studentId\": 2,  \n  \"courseId\": 2\n}\n```\n### Get Students\n``` json\n[\n  {\n    \"id\": 1,\n    \"name\": \"Student-1\",\n    \"studentsCourses\": [\n      {\n        \"id\": 1,\n        \"studentId\": 1,\n        \"student\": null,\n        \"courseId\": 1,\n        \"course\": null\n      }\n    ]\n  },\n  {\n    \"id\": 2,\n    \"name\": \"Student-2\",\n    \"studentsCourses\": [\n      {\n        \"id\": 2,\n        \"studentId\": 2,\n        \"student\": null,\n        \"courseId\": 1,\n        \"course\": null\n      },\n      {\n        \"id\": 3,\n        \"studentId\": 2,\n        \"student\": null,\n        \"courseId\": 2,\n        \"course\": null\n      }\n    ]\n  }\n]\n```\n### Get Courses\n``` json\n[\n  {\n    \"id\": 1,\n    \"name\": \"BA\",\n    \"studentsCourses\": [\n      {\n        \"id\": 1,\n        \"studentId\": 1,\n        \"student\": null,\n        \"courseId\": 1,\n        \"course\": null\n      },\n      {\n        \"id\": 2,\n        \"studentId\": 2,\n        \"student\": null,\n        \"courseId\": 1,\n        \"course\": null\n      }\n    ]\n  },\n  {\n    \"id\": 2,\n    \"name\": \"BSC\",\n    \"studentsCourses\": [\n      {\n        \"id\": 3,\n        \"studentId\": 2,\n        \"student\": null,\n        \"courseId\": 2,\n        \"course\": null\n      }\n    ]\n  }\n]\n```\n### Get StudentsCourses\n``` json\n[\n  {\n    \"id\": 1,\n    \"studentId\": 1,\n    \"student\": {\n      \"id\": 1,\n      \"name\": \"Student-1\",\n      \"studentsCourses\": [\n        null\n      ]\n    },\n    \"courseId\": 1,\n    \"course\": {\n      \"id\": 1,\n      \"name\": \"BA\",\n      \"studentsCourses\": [\n        null,\n        {\n          \"id\": 2,\n          \"studentId\": 2,\n          \"student\": {\n            \"id\": 2,\n            \"name\": \"Student-2\",\n            \"studentsCourses\": [\n              null,\n              {\n                \"id\": 3,\n                \"studentId\": 2,\n                \"student\": null,\n                \"courseId\": 2,\n                \"course\": {\n                  \"id\": 2,\n                  \"name\": \"BSC\",\n                  \"studentsCourses\": [\n                    null\n                  ]\n                }\n              }\n            ]\n          },\n          \"courseId\": 1,\n          \"course\": null\n        }\n      ]\n    }\n  },\n  {\n    \"id\": 2,\n    \"studentId\": 2,\n    \"student\": {\n      \"id\": 2,\n      \"name\": \"Student-2\",\n      \"studentsCourses\": [\n        null,\n        {\n          \"id\": 3,\n          \"studentId\": 2,\n          \"student\": null,\n          \"courseId\": 2,\n          \"course\": {\n            \"id\": 2,\n            \"name\": \"BSC\",\n            \"studentsCourses\": [\n              null\n            ]\n          }\n        }\n      ]\n    },\n    \"courseId\": 1,\n    \"course\": {\n      \"id\": 1,\n      \"name\": \"BA\",\n      \"studentsCourses\": [\n        {\n          \"id\": 1,\n          \"studentId\": 1,\n          \"student\": {\n            \"id\": 1,\n            \"name\": \"Student-1\",\n            \"studentsCourses\": [\n              null\n            ]\n          },\n          \"courseId\": 1,\n          \"course\": null\n        },\n        null\n      ]\n    }\n  },\n  {\n    \"id\": 3,\n    \"studentId\": 2,\n    \"student\": {\n      \"id\": 2,\n      \"name\": \"Student-2\",\n      \"studentsCourses\": [\n        {\n          \"id\": 2,\n          \"studentId\": 2,\n          \"student\": null,\n          \"courseId\": 1,\n          \"course\": {\n            \"id\": 1,\n            \"name\": \"BA\",\n            \"studentsCourses\": [\n              {\n                \"id\": 1,\n                \"studentId\": 1,\n                \"student\": {\n                  \"id\": 1,\n                  \"name\": \"Student-1\",\n                  \"studentsCourses\": [\n                    null\n                  ]\n                },\n                \"courseId\": 1,\n                \"course\": null\n              },\n              null\n            ]\n          }\n        },\n        null\n      ]\n    },\n    \"courseId\": 2,\n    \"course\": {\n      \"id\": 2,\n      \"name\": \"BSC\",\n      \"studentsCourses\": [\n        null\n      ]\n    }\n  }\n]\n```\n# Relationships\nHere’s the explanation of the relationships along with **models** and **table structures** for each type:\n\n---\n\n### **1. One-to-One Relationship**\n#### Example: `User` and `Profile`\n\n#### Models\n```csharp\npublic class User\n{\n    public int Id { get; set; }\n    public string Name { get; set; } = null!;\n    public Profile? Profile { get; set; }\n}\n\npublic class Profile\n{\n    public int Id { get; set; }\n    public string Bio { get; set; } = null!;\n    public int UserId { get; set; }\n    public User? User { get; set; }\n}\n```\n\n#### Table Structure\n**Table: `Users`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the user.  |\n| `Name`          | `string`      | `NO`         | Name of the user.          |\n\n**Table: `Profiles`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the profile. |\n| `Bio`           | `string`      | `NO`         | Biography of the user.     |\n| `UserId`        | `int`         | `NO`         | Foreign key referencing `Users.Id`. |\n\n---\n\n### **2. One-to-Many Relationship**\n#### Example: `Blog` and `Post`\n\n#### Models\n```csharp\npublic class Blog\n{\n    public int Id { get; set; }\n    public string Title { get; set; } = null!;\n    public ICollection\u003cPost\u003e? Posts { get; set; }\n}\n\npublic class Post\n{\n    public int Id { get; set; }\n    public string Content { get; set; } = null!;\n    public int BlogId { get; set; }\n    public Blog? Blog { get; set; }\n}\n```\n\n#### Table Structure\n**Table: `Blogs`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the blog.  |\n| `Title`         | `string`      | `NO`         | Title of the blog.         |\n\n**Table: `Posts`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the post.  |\n| `Content`       | `string`      | `NO`         | Content of the post.       |\n| `BlogId`        | `int`         | `NO`         | Foreign key referencing `Blogs.Id`. |\n\n---\n\n### **3. Self-Referential Relationship**\n#### Example: `Employee` with Manager\n\n#### Models\n```csharp\npublic class Employee\n{\n    public int Id { get; set; }\n    public string Name { get; set; } = null!;\n    public int? ManagerId { get; set; }\n    public Employee? Manager { get; set; }\n    public ICollection\u003cEmployee\u003e? Subordinates { get; set; }\n}\n```\n\n#### Table Structure\n**Table: `Employees`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the employee. |\n| `Name`          | `string`      | `NO`         | Name of the employee.      |\n| `ManagerId`     | `int`         | `YES`        | Foreign key referencing `Employees.Id`. |\n\n---\n\n### **4. Polymorphic Relationship**\n#### Example: `Comment` can belong to multiple entities (`Post`, `Photo`)\n\n#### Models\n```csharp\npublic class Comment\n{\n    public int Id { get; set; }\n    public string Content { get; set; } = null!;\n    public int ParentId { get; set; }\n    public string ParentType { get; set; } = null!; // Example: \"Post\", \"Photo\"\n}\n```\n\n#### Table Structure\n**Table: `Comments`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the comment. |\n| `Content`       | `string`      | `NO`         | Content of the comment.    |\n| `ParentId`      | `int`         | `NO`         | Foreign key referencing the parent entity. |\n| `ParentType`    | `string`      | `NO`         | Indicates the parent entity type (e.g., `Post` or `Photo`). |\n\n---\n\n### **5. Many-to-Many with Extra Attributes**\n#### Example: `Student` enrolls in `Course` with additional attributes like `EnrollmentDate`\n\n#### Models\n```csharp\npublic class Student\n{\n    public int Id { get; set; }\n    public string Name { get; set; } = null!;\n    public ICollection\u003cStudentCourse\u003e? StudentCourses { get; set; }\n}\n\npublic class Course\n{\n    public int Id { get; set; }\n    public string Name { get; set; } = null!;\n    public ICollection\u003cStudentCourse\u003e? StudentCourses { get; set; }\n}\n\npublic class StudentCourse\n{\n    public int Id { get; set; }\n    public int StudentId { get; set; }\n    public Student? Student { get; set; }\n    public int CourseId { get; set; }\n    public Course? Course { get; set; }\n    public DateTime EnrollmentDate { get; set; }\n    public string Grade { get; set; } = null!;\n}\n```\n\n#### Table Structure\n**Table: `Students`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the student. |\n| `Name`          | `string`      | `NO`         | Name of the student.        |\n\n**Table: `Courses`**\n| **Column Name** | **Data Type** | **Nullable** | **Description**            |\n|------------------|---------------|--------------|----------------------------|\n| `Id`            | `int`         | `NO`         | Primary key for the course. |\n| `Name`          | `string`      | `NO`         | Name of the course.         |\n\n**Table: `StudentCourses`**\n| **Column Name**      | **Data Type** | **Nullable** | **Description**                |\n|-----------------------|---------------|--------------|--------------------------------|\n| `Id`                 | `int`         | `NO`         | Primary key for the record.    |\n| `StudentId`          | `int`         | `NO`         | Foreign key referencing `Students.Id`. |\n| `CourseId`           | `int`         | `NO`         | Foreign key referencing `Courses.Id`.  |\n| `EnrollmentDate`     | `datetime`    | `NO`         | Date of enrollment.            |\n| `Grade`              | `string`      | `NO`         | Grade achieved in the course.  |\n\n---\n\nThese examples show how different types of relationships can be modeled and structured in databases. Let me know if you need additional assistance! 😊\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanusoft%2Fef-core-relation-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanusoft%2Fef-core-relation-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanusoft%2Fef-core-relation-demo/lists"}