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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:54:41+00:00 2026-05-28T22:54:41+00:00

I have entity Territory class Territory { public int Id {get;set;} public string Title

  • 0

I have entity Territory

    class Territory
    {
      public int Id {get;set;}
      public string Title {get;set;}
    }

and some entities which have references to it, such as

    class MyObject
    {
      public Territory Territory {get;set;}
    }

and mapping in FluentNHibernate

    References(x => x.Territory)
            .Column("TerritoryId")
            .Nullable()                
            .Not.LazyLoad()
            .Cascade.None();

and when I’m deleting territory I have error: The DELETE statement conflicted with the REFERENCE constraint “FK377ABC4DAD038F1B”. The conflict occurred in database “GPM_Test”, table “dbo.MyObject”, column ‘TerritoryId’.

How can I make nhibernate set FK to NULL before territory is deleted?

I need something like in SQL

    ON DELETE set NULL
  • 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-28T22:54:41+00:00Added an answer on May 28, 2026 at 10:54 pm

    I would say you have to delete the links between the entities first before you can delete the object itself, this can ofcourse be done in the database by cascade deletion. Another way is to programmicaly removed the links between the entity you want to remove and the related tables.

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

Sidebar

Related Questions

I have entity class: public class Project { public virtual int Id { get;
I have Entity set and i create partial class [Bind(Include = ID,Note,Spec,Retired)] [MetadataType(typeof(SomeClass))] public
Let's say we have: @Entity public class Order { @Id private int id; @OneToMany(mappedBy=order)
I have Entity Framework entities Events which have an EntityCollection of RSVP. I want
I have an entity similar to the below: public class Entity { public List<DateItem>
Hibernate allows you to just say .id. Let's say I have: @Entity public class
I have entity objects: @Entity public class Tag { @Id private Long id; @Transient
I have entity called Customer and it has three properties: public class Customer {
Technology: Hibernate 3.0 Suppose i have Entity class Company @Entity @Table(name=tbl_companies) public class Company
I have entity class which is used to model a weather station, and it

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.