![]() ![]() net framework ADO.NET Angular angular-router AngularFire Application Insights asp.net ASP.NET Core asp.net core 2.0 ASP.NET CORE 2.1 ASP.NET CORE 2.2 ASP.NET Core 6 aspnetusers Asynchronous Programming Audit AutoMapper automatic tests azure app service Azure SQL Blazor class Cloud Firestore Content-Type Content Negotiation Database First Dependency Injection dotnet CLI DropDownList Entity Framework Entity Framework Core 2.0 Entity Framework Core 2.1 Entity Framework Core 2.Follow me! Tags Cloud. Mounting Identity with Database First - ASP.NET Core.ASP.NET Core 3.1: Using Factories in the Dependency Injection System.Using Events with JavaScript and jQuery in Blazor - Initializing Libraries.Solving the error: "No packages exist with this id" in Visual Studio.Entity Framework Core: Foreign key linked with a non-primary key.Getting the IConfiguration in the Program class - ASP.NET Core 6.Configuring Entity Framework Core with Dynamic Connection Strings - ASP.NET Core.Passing a List of Values to a Stored Procedure from C#.Fixing the error "A possible object cycle was detected" in different versions of ASP.NET Core.Fixing the error “A possible object cycle was detected” in different versions of ASP.NET Core May 19, 2021.Mounting Identity with Database First – ASP.NET Core June 25, 2021.Getting the IConfiguration in the Program class – ASP.NET Core 6 August 19, 2021.Solving the error: “No packages exist with this id” in Visual Studio September 2, 2021.Passing a List of Values to a Stored Procedure from C# April 20, 2022.Introduction to Concurrency in C# – Async and Paralellism: Įnter your email address to follow this blog and receive notifications of new posts by email. ![]() Building RESTful Web APIs with ASP.NET Core 3.1:.Programming in Blazor – ASP.NET Core 5:.Building Applications with Angular 11 and ASP.NET Core 5:.Building Applications with React 17 and ASP.NET Core 6:.The following links have a discount code applied: If you want to learn more, check out my Udemy courses today. We can use HasPrincipalKey to define with which field we want to link our foreign key.With Entity Framework Core we can define relationships between our models.From here we can add our migrations and proceed with the development of our application. Now with this, we are marking MenuCode of the Menu class as the principal key, which means that it will be the destiny of the one-to-one relationship, in other words, the link will be made between the Route’s MenuCode and the Menu’s MenuCode. We can configure the PrincipalKey in the following manner: Once we configure a field as PrincipalKey, the unique constraint will automatically be applied. The unique constraint means that values cannot be repeated in different entries in a column. We emphasize that the reference column of the other table must have unique values, that is, it must have a unique constraint. That is to say, with the PrincipalKey we can say that we want to link our foreign key MenuCode of the class Route, with the field MenuCode of the class Menu. ![]() The PrincipalKey will allow us to define the reference key with a unique restriction which will be the destination of the relationship. The solution is to configure the PrincipalKey. What we want is to link MenuCode of Route with MenuCode of Menu. The problem is that MenuCode is a string and Id is an integer, therefore, they are not compatible. This error occurs because you are trying to link MenuCode of the class Route with Id of the class Menu. Configure a principal key or a set of compatible foreign key properties for this relationship. The relationship from ‘Menu.Route’ to ‘Route.Menu’ with foreign key properties because it is not compatible. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |