Error when creating Database using Entity Framework Core
I am getting the error bellow when I try to create my database using Entity Framework Core:
Introducing FOREIGN KEY constraint 'FK_StudentAnnouncements_Students_StudentId' on table 'StudentAnnouncements' 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.
I have a one to many relationship between Student and StudentAnnouncements. My Student entity has the code below:
public class Student
{
public int Id { get; set; }
public virtual ICollection<StudentAnnouncement> StudentAnnouncements { get; set;}
}
My StudentAnnouncement entity has the code below:
public class StudentAnnouncement
{
public int Id { get; set; }
public int StudentId { get; set; }
public virtual Student Student { get; set; }
}
When I create a migration and update the database using [dotnet ef database update] I get the error.