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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:23:08+00:00 2026-05-25T02:23:08+00:00

I have a object Customer , this object has an ISet list of Contact

  • 0

I have a object Customer, this object has an ISet list of Contact. When I delete a Customer I’d like to delete the Contact.

I use the mapping below, I tried all option in cascade but still have this problem :
The DELETE statement conflicted with the REFERENCE constraint “FK4FF8F4B29499D0A4”. The conflict occurred in database “MyDB”, table “dbo.Contact”, column ‘Customer’.

The mapping Customer

<set name="Contacts" table="CustomerContact" cascade="save-update">
    <key column="Customer" />
    <many-to-many class="Contact" column="Contact" />
</set>

The mapping Contact

<many-to-one name="Customer" column="Customer" not-null="true" />
  • 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-25T02:23:08+00:00Added an answer on May 25, 2026 at 2:23 am

    It is strange that you have bidirectional association between customer and contact mapped like that. If Customer can be associated with multiple Contacts, and vice versa, you should have many-to-many on both sides. But you have many-to-one at Contact side. And you mention that you want to cascade deletes to Contact.

    Perhaps you should consider mapping Contacts collections as one-to-many? Try this for Customer mapping, note inverse attribute.

    <set name="Contacts" 
         table="CustomerContact" 
         inverse="true" 
         cascade="all-delete-orphan" >
    
        <key column="Customer" />
        <one-to-many class="Contact" />
    </set>
    

    With this Contact mapping:

    <many-to-one name="Customer" column="Customer" />
    

    You will also have to ‘chase the pointers’: null out Customer.Contact when corresponding Contact is removed from Customer.Contacts collection.

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

Sidebar

Related Questions

Suppose I have a customer object that has all of the standard customer properties
I have a Customer object that has a child Orders collection. I have this
I have a Customer object which has a collection of ContactNumbers. Is it possible
I have a basic Customer/Order/OrderItem/Product object graph. Customer has Many Orders, Order has Many
I have a Customer class which has all the account info.(it does NOT extend
I have this structure Customer - has many Orders - has many OrderItems I
I have a method that receives a customer object which has changed properties and
I have a form changeed the properties of my object CUSTOMER. Each customer has
In WPF, I have a static Customer object in the definition for MainWindow.xaml.cs. This
Say we have a class of Customer and that has a child object of

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.