Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4847

Error message when doing Update-Database in Blazor using VIsual Studio [duplicate]

$
0
0

when I run Update-Database command after creating a new migration, I get the following error:

Introducing FOREIGN KEY constraint 'FK_Booking_Employee_EmployeeId' on table 'Booking' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.Could not create constraint or index. See previous errors.

However, I am not quite sure how to fix this.

My Booking model:

using System.ComponentModel.DataAnnotations.Schema;namespace SpaWebsite.Models{    public class Booking    {        public int BookingId { get; set; }        [ForeignKey("Service")]        public int ServiceId { get; set; }        public Service? Service { get; set; }        [ForeignKey("Customer")]        public int CustomerId { get; set; }        public Customer? Customer { get; set; }        [ForeignKey("Employee")]        public int EmployeeId { get; set; }        public Employee? Employee { get; set; }        public DateTime StartTime { get; set; }        public DateTime EndTime { get; set; }        public decimal Price { get; set; }        public string? Description { get; set; }        public bool Status { get; set; }    }}

My Employee model:

using System.ComponentModel.DataAnnotations.Schema;namespace SpaWebsite.Models{    public class Employee    {        public int EmployeeId { get; set; }        [ForeignKey("User")]        public int Id { get; set; }        public User? User { get; set; }        public string? FirstName { get; set; }        public string? LastName { get; set; }        public DateTime HireDate { get; set; }        public string? Phone { get; set; }        public string? Role { get; set; }    }}

Can anyone please assist in how to fix the error so I can update my database? Thanks in advance.


Viewing all articles
Browse latest Browse all 4847

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>