Krutss
Krutss
CC#
Created by Krutss on 6/3/2023 in #help
❔ Dotnet migration help
hello, i realy need help with this im wokring on asp.net and im trying to establish this optinal connection // One-to-Many: CoffeeShop to Users (Employees and Managers) builder.Entity<CoffeeShop>() .HasMany(cs => cs.Employees) .WithOne(u => u.CoffeeShop) .HasForeignKey(u => u.CoffeeShopId) .IsRequired(false);` and i got public class User : IdentityUser<Guid>{ ... public Guid? CoffeeShopId { get; set; } public CoffeeShop? CoffeeShop { get; set; } } and public class CoffeeShop { public List<User> Employees { get; set; } } now every time i try to register (I register with a null CoffeeShopId) i get this exception qlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_AspNetUsers_CoffeeShops_CoffeeShopId". The conflict occurred in database "LuxusCoffee2", table "dbo.CoffeeShops", column 'Id'. and i dont know why since its null it shouldnt trigger anything dont know if i overdid it, but im desperate
4 replies