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 7173203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:46:31+00:00 2026-05-28T15:46:31+00:00

I have started this support ticket project where users can create tickets and the

  • 0

I have started this “support ticket” project where users can create tickets and the admin and user can both respond. I’m faily new to MVC3. I solve most issues on my own, but I have spent about 5 hours on this one searching Google/Stackoverflow and I just can’t figure it out… so I’ve come to the experts.

This is the error:

The INSERT statement conflicted with the FOREIGN KEY constraint
“FK_Reponses_Tickets1”. The conflict occurred in database
“C:\USERS\ME\DOCUMENTS\VISUAL STUDIO
2010\PROJECTS\TICKETSYSTEM\TICKETSYSTEM\APP_DATA\TICKETSYSTEM.MDF”,
table “dbo.Tickets”, column ‘ID’.

Source Error:

Line 21:             response.Body = body;
Line 22:             model.AddToReponses(response);
Line 23:             model.SaveChanges();
Line 24:             return RedirectToAction("Ticket", new { id = id });
Line 25:            }

Here is the full controller action:

        public ActionResult Responses(int id, string body)
        {
            Ticket ticket = GetTicket(id);
            Response response = new Response();
            response.Body = body;
            model.AddToReponses(response);
            model.SaveChanges();
            return RedirectToAction("Ticket", new { id = id });
        }

For those wondering, I’ve been following the tutorial “From Zero to Blog in 100 Minutes” by matthewblagden (YouTube) but using it as a ticket system instead of a blog. I’ve following him line by line as I can tell.

Any help would be appreciated. Thanks.

  • 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-05-28T15:46:32+00:00Added an answer on May 28, 2026 at 3:46 pm

    Assuming every one of your responses is associated with a ticket somehow, you need to do this in your code, too!

    public ActionResult Responses(int id, string body)
    {
        // get the ticket
        Ticket ticket = GetTicket(id);
    
        // create resposne
        Response response = new Response();
        response.Body = body;
    
        // *** BEGIN NEW SECTION ***
        // here, you need to ASSOCIATE your response to the ticket you're retrieved!
        response.Ticket = ticket;  // or something like that......
    
        // or maybe:
        response.TicketId = ticket.Id;  // or something like that......
        // *** END NEW SECTION ***
    
        model.AddToReponses(response);
        model.SaveChanges();
    
        return RedirectToAction("Ticket", new { id = id });
    }
    

    Right now, you have stand-alone responses (not associated with any Ticket) – and that obviously doesn’t work in your database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help me getting started with this? We have a current keygen for
Since I have started using this site, I keep hearing about the Boost library.
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
I honestly have only started recently researching this so my knowledge is limited. I
This is a weird problem I have started having recently. My team is developing
I have recently started learning F#, and this is the first time I've ever
Ever since I started programming this has been something I have been curious about.
This discussion started over here but I thought it would be nice to have
I have only recently started working with the MVC approach, so I suppose this
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM

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.