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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:53:01+00:00 2026-06-11T01:53:01+00:00

I am attempting to delete a series of entities using EntityFramework 4. Here is

  • 0

I am attempting to delete a series of entities using EntityFramework 4. Here is the code I am using:

var role = (
    from r in context.tblAdminRoles
    where r.AdminRoleId == this.Role.AdminRoleId
    select r
).First();

this.AdminUser.tblAdminRoles.Remove(role);
context.SaveChanges();

context.tblAdminRoles.Remove(role);
context.SaveChanges();

However, when I execute it, I get the following error:

The DELETE statement conflicted with the REFERENCE constraint "FK_tblAdminUserRole_tblAdminRole". The conflict occurred in database "MyMainSite2", table "dbo.tblAdminUserRole", column 'AdminRoleId'.

The statement has been terminated.

My database has the following structure:

----------------      --------------------      ----------------
|              |      |                  |      |              |
| tblAdminUser | ---< | tblAdminUserRole | >--- | tblAdminRole |
|              |      |                  |      |              |
----------------      --------------------      ----------------

Can anyone point me in the right direction about what might be going wrong?

  • 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-11T01:53:02+00:00Added an answer on June 11, 2026 at 1:53 am

    Check if cascading delete is enabled in the database for the two relationships refering to the link table tblAdminUserRole, especially for the FK_tblAdminUserRole_tblAdminRole to the tblAdminRole table. It looks like it isn’t enabled, therefore deleting the role doesn’t delete the entries in the link table which finally leads to the FK constraint violation.

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

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to delete files from the documents directory using a tableview/array combination. For
I am attempting to delete a C# based Windows Service from the DOS command
I am using hibernate 3 and attempting to delete a record in the database,
I am attempting to iterate through a HTML table using jQuery and delete empty
I am attempting to delete files based on a pattern from all directories contained
I am attempting this in the JavaScript language using the Titanium IDE. What I'm
I am attempting to remove a value from an array using splice. starting at
I am attempting to delete a record from the Django admin interface. I click
Attempting to change the files folder location in a Drupal site from /files to

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.