locked
Entity.Delete() on a 1..1 relationship. RRS feed

  • Question

  • Greetings once again! Smile

     

    I'm using Orcas Beta 1, and I'm trying to delete an entity that has a 1..1 relationship with another entity.  However, when I SaveChanges(), I get an exception saying:

     

     System.Data.UpdateException: Entities in 'Countries' participate in the 'CountrySettings_Country' relationship. 0 related 'CountrySettings' were found. Between 1 and 1 'CountrySettings' are expected..

     

    Now, I can make this go away by modifying the Association in the CSDL file to hold a referential constraint, and making the multiplicity 0..1.  I'm looking to maintain a 1..1 and cascade the delete to the associated entity.  Is this possible? Smile

     

    Thanks!

    Saturday, July 21, 2007 3:39 AM

Answers

  • I don't remember if we supported Cascade delete in Beta1.

    But here is the way to specify Cascade delete behavior in the csdl( Some of these Multiplicity values might be different in Beta1 bits),

       <Association Name="CProductCategory">
            <End Type="Self.CProduct" Multiplicity="*" />
            <End Type="Self.CCategory" Multiplicity="0..1">
                <OnDelete Action="Cascade" />
            </End>
         </Association>

     

    Thanks

    Srikanth

    Saturday, July 21, 2007 3:57 AM

All replies

  • I don't remember if we supported Cascade delete in Beta1.

    But here is the way to specify Cascade delete behavior in the csdl( Some of these Multiplicity values might be different in Beta1 bits),

       <Association Name="CProductCategory">
            <End Type="Self.CProduct" Multiplicity="*" />
            <End Type="Self.CCategory" Multiplicity="0..1">
                <OnDelete Action="Cascade" />
            </End>
         </Association>

     

    Thanks

    Srikanth

    Saturday, July 21, 2007 3:57 AM
  • Right you are!  My goodness I need to get a little more familiar w/ this schema. Smile  Thanks a bunch!
    Saturday, July 21, 2007 3:59 AM
  • I have the same issue I posted a question here, I checked the csdl, the OnDelete is set to Cascade, but I still get the exception.

    What would be best delete practices?

    Thanks.


    Shimmy
    Saturday, March 28, 2009 10:53 PM