Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7796885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:30:33+00:00 2026-06-01T23:30:33+00:00

I am a bit confused as to why I am getting this error: Introducing

  • 0

I am a bit confused as to why I am getting this error:

Introducing FOREIGN KEY constraint 'FK_QuestionTerms_Terms_TermId' 
on table 'QuestionTerms' 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. See previous errors.

I have a class Question and a class Term, Questions may have any number of Terms associated with them, and Terms may have any number of Questions associated with them. So I am attempting to create a many to many relationship between the two. First I attempted to use convention, and I am allowing EntityFramework to create the database. This is the Question class

public class Question
{
    public Guid Id { get; set; }
    public int QuestionNumber { get; set; }
    public string StatementHtml { get; set; }
    public string AnswerHeaderHtml { get; set; }
    public string NotesHtml { get; set; }
    public Guid CategoryId { get; set; }
    public Guid CourseId { get; set; }
    public Guid QuestionTypeId { get; set; }
    public Guid? SimulationId { get; set; }
    public Guid? SimulationTabId { get; set; }

    public ICollection<Term> Terms { get; set; }
    public ICollection<ReferenceItem> ReferenceItems { get; set; }

}

And here is the Term Class

public class Term
{
   public Guid Id { get; set; }
   public string Name { get; set; }
   public string StatementHtml { get; set; }
   public string Authority { get; set; }
   public Guid ProductId { get; set; }

   public Product Product { get; set; }
   public ICollection<Question> Questions { get; set; }
}

I have also attempted to override OnModelCreating as follows, both process result is the exact same error code.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Entity<Question>()
        .HasMany(q => q.Terms)
        .WithMany(t => t.Questions)
        .Map(x =>
            {
                x.MapLeftKey("QuestionId");
                x.MapRightKey("TermId");
                x.ToTable("QuestionTerms");
            });
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:30:34+00:00Added an answer on June 1, 2026 at 11:30 pm

    The problem is that a cacade delete would go back and forth between the tables.

    For example first deleting term A which would delete question 1,2 and 3. Question 1 was also used in term B so term B must be deleted …..

    It therefore stops you creating such constraints.

    There is a good coverage of how to fix it here: Entity Framework 4.1 InverseProperty Attribute and ForeignKey

    Edit

    This could be a side effect of other problems. You should start with a much simpler model and then gradually build it up.

    For example:

    • Why do you have both ProductId and product
    • Why CategoryId and not Category
      …
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm a bit confused on this error that I'm getting while compiling/linking a
I am getting myself a bit confused about how to go about this. My
This might be a very basic question, but I'm getting a bit confused. I'm
This should be obvious, but I'm getting a bit confused about PHP variable scope.
I'm getting a bit confused with the new threading in C++11. I get how
I am getting a bit confused. I am creating an app with storyboard, and
Switching to GCC for the first time, and I'm getting a bit confused by
I'm a bit confused why I can't initialize a getter this way: @synthesize stack
I'm getting a bit confused on how to use the simulator to build applications
I'm a little bit confused about how to approach this. I had never used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.