Sitemap

Amicuk Programming Answers

EF database first cascades delete despite cascade is restricted in db and edmx setting End1/2 OnDelete = "None"

-0001-11-30   Views:2

Advertisement

We are developing with Visual Studio 2013, Entity Framework 5, Oracle DB 11 via ODP.NET managed driver. The edmx is generated/updated from database (database first). We generate POCO object using standard T4. We have 2 tables with a master-detail for

We are developing with Visual Studio 2013, Entity Framework 5, Oracle DB 11 via ODP.NET managed driver.
The edmx is generated/updated from database (database first). We generate POCO object using standard T4.
We have 2 tables with a master-detail foreign key relation, one to many. The foreign key in database does _not_ allow cascade deletes, so when you delete master row via SQL, you get error " ... child record found ... ".
The problem now is:
In Entity Framework, when i delete a record from the master table, then EF also deletes all corresponding detail records from the detail table! The restriction of the foreign key in database is ignored.
In edmx diagram, the properies End1 OnDelete / End2 OnDelete are set to "None", so i expect that on delete of a master row, EF should throw an error if detail rows exists.
How can i disable the cascading of the delete?
Here is the FK definition in edmx:
        <Association Name="USR_USER_ROLES_ROLES_FK">
          <End Role="USR_ROLES" Type="Self.USR_ROLES" Multiplicity="1" />
          <End Role="USR_USER_ROLES" Type="Self.USR_USER_ROLES" Multiplicity="*" />
          <ReferentialConstraint>
            <Principal Role="USR_ROLES">
              <PropertyRef Name="GES" />
              <PropertyRef Name="PROJ" />
              <PropertyRef Name="ROLE_NAME" />
            </Principal>
            <Dependent Role="USR_USER_ROLES">
              <PropertyRef Name="GES" />
              <PropertyRef Name="PROJ" />
              <PropertyRef Name="ROLE_NAME" />
            </Dependent>
          </ReferentialConstraint>
        </Association> 
 The delete of master row is done by calling:
ivDbCtx.USR_Roles.Local.Remove(role); // ivDbCtx is the DbContext, USR_Roles is the collection, role is the POCO object to be deleted.
Thank you very much for your help!
Udo

The replay answer
Advertisement
Hello,
For issues regarding ODP.NET managed driver, I would suggest you posting to oracle entity framework forum:
https://community.oracle.com/communications
There are oracle entity framework expects who will help you better.
Thanks for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Go to See the other 2 answers

EF database first cascades delete despite cascade is restricted in db and edmx setting End1/2 OnDelete = "None"

Category:DefaultRelease time:-0001-11-30Views:130

We are developing with Visual Studio 2013, Entity Framework 5, Oracle DB 11 via ODP.NET managed driver. The edmx is generated/updated from database (database first). We generate POCO object using standard T4. We have 2 tables with a master-detail for[More]

Rollback in database adapter with delete polling strategy

Category:DefaultRelease time:2015-10-11Views:130

Hi All, We have designed a database adapter with "Delete the Rows That Were Read" after read strategy with auto-retry attempts as 5. In BPEL process, where we are receiving the DB records, we are throwing a rollback fault in case of any fault. D[More]

Exchange 2007 Public Folder Database cannot be deleted

Category:DefaultRelease time:2015-10-11Views:130

We are in the process of decommissioning exchange 2007 server from 2007 <-> 2013 coexistence. All user MailboxDatabases have been sucsessfully removed, however PF Mailbox databases return an error.  "The public folder database 'Public Folder Da[More]

How to use icons (database, database backup, save, delete etc.) in Oracle f

Category:DefaultRelease time:-0001-11-30Views:130

Hi Everyone, I am using Oracle forms 5. I want to use iconic buttons in Oracle forms 5 for database, database backup, save, delete etc. Example: Like Oracle Enterprise Manager, a GUI tool, we can see the different icons for different items (icon for[More]

Poll Database Adapter Physicial Delete strategy

Category:DefaultRelease time:-0001-11-30Views:130

Guys, The database adapter should delete the record from table only if the record was processed successfully in esb or BPEL. But as far as i tested it deletes the polled record regardless of success or fault. Is there any setting that I need to do to[More]

Let the database doing cascade deletion for privateOwned relationship

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have two tables: parent, child. I mapped the parent to child as a one-many private owned relationship. The child table have a foreign key reference back to parent table. The constraint is like this alter table child add constraint FK_CONSTRAINT[More]

Virtual private database and cascade delete

Category:DefaultRelease time:-0001-11-30Views:130

We can't secure rows deleted by cascade delete by vpd. User "A" have right to delete row "1" but don't have right to delete row "2". If user "A" delete row "1", database will delete also row "2"[More]

How can I add a url parameter to choose the right database row to delete using php in Dreamweaver CC

Category:DefaultRelease time:2015-10-11Views:130

Hi all, I have just upgraded to Adobe Creative Cloup.  Though I find it very good there was one flaw and that was the omision of the database section.  I got this sorted but now I find that once I have set up the connection to the database and want t[More]

Database Adapter Logical Delete Not Working....

Category:DefaultRelease time:2015-10-11Views:130

Hi, I have an issue with the DB Adapter under BPEL GA 10.1.3.1. I'm trying to do a logical delete on a table however the logical delete isn't updating the records to show that they've been processed. I've created a simple test case with a 3 column ta[More]

Database performance degrade - delete operation

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have a big database. One of the table contains 120 milion records and many tables (more than 50) has referential integrity to this table. Table structure Customer (Cust_ID, and other columns). Cust_ID is Primary Key. Other tables has referentia[More]

How to reduce the database size after deleting huge amount of rows?

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have a large database. I removed almost half of the data/rows. Now i need to reduce the size of the database file as I need more disk space for the database file. What should I do in details please. Thanks.Hi, I have a large database. I removed[More]

Hot
On our family pc we log in with different accounts. We want to use I-Tunes but all have the same library. I tried to create a library not in the users directory, but in the All Users folder that is accessible for everyone. However, when I import the [More]
I have somehow collected 3 IDs over the years and want to merge them so I don't keep having to log out and resign in every time I need to update my apps on my iPhone and iPad. Any thoughts? Thanks!Apple IDs cannot be merged. See here: http://support. [More]
system specs are as follows Operating System: Windows XP Professional (5.1, Build 2600) Service Pack 2 (2600.xpsp_sp2_qfe.061219-0311) Language: English (Regional Setting: English) System Manufacturer: Dell Inc. System Model: Dell DM051 BIOS: Phoenix [More]
Does anybody know of a way to have a playlist play tracks in a certain order without changing the track number? I don't want to do this because some of the tracks in my playlist are from albums and changing the track number in the playlist obviously [More]
Hi, Which settings are needed to import IDocs into XI respectively in SAP Backend System and XI system. Thanks, Regards MortenHi, These links help you: Settings for Idoc Creation on Transaction ALE settings for MIRO outbound IDOC http://help.sap.com/ [More]
I use smart playlists to select and control what podcasts goto my ipod as the standard podcasting sync controls are pretty lame. Where is the order by release date colum? (show colum option) so why is this not included as an option? Oh and as a hint [More]
How do you save your artwork in Photoshop CC 2014 as an PNG or JPEG file when it doesn't give the option? Thanks for your time and help in advance.Thanks for replying. I actually got it to work. I had my work set to 32 Bits/Channel in stead of 16 or [More]
My iPod Touch 4th generation keeps popping up Voice Command by itself and keeps stopping and adjusting the volume by itself. Why is it doing this? There's absolutely no damage to it....I haven't dropped it and there's no water damageDid you already t [More]
After downloading new Software Epson Scan (v3.791) 03-Dec-2013 from http://www.epson.co.uk/gb/en/viewcon/corporatesite/products/mainunits/support/12 304 all scanning features were operational again. BUT When updating further to OS X 10.9.1 scanner we [More]
Hi, I am using the Portal content translation for translating the text from English to Swedish. The problem is the changes do not reflect even after Publishing the Translation Worklist. Any idea where this is cached? It works after the restart of Por [More]