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
I get the following error when I try to create a new package in CCP 6/18/2013 13:27:26[INFO] AdobePackageBuilder - Build Version - 1.0.0.55 6/18/2013 13:27:26[INFO] AdobePackageBuilder - Logging Level verbosity Set  to 4 6/18/2013 13:27:27 [WARN] Ado [More]
The new one will not stay behind the taskbar no matter what I do, and I do not want the address bar or tabs disappearing. I have had it with trying figure the new version out. I just want an earlier copy.Are you running Firefox in full screen mode? * [More]
Hi, I have a problem in JSP. I want to open a jsp page in read only mode. How I can do this?Can you explain what you mean by "open a jsp page in read only mode"? open the jsp file in an editor in read only mode? load the jsp page only once all b [More]
Hi All, I have installed HCM 9 with 8.49.08 PeopleTools on CentOS 5.3 Linux. Everything went fine (I have completed the creation of database) until I am about to start the application server that I have just created. I am getting this error, "TMADMIN [More]
Hi Can anyone advise on the most appropriate way to 'size' for a new Content Server. Documents have been stored in the SAP DB till now, but the use is increasing, so now a new Content Server is to be added and all existing documents migrated into it. [More]
Hi, I'm currently experiencing issues when trying to log on to an FTP server I created using Windows Server 2008 R2. The FTP web site has Enabled both Anonymous and Basic Authentication. On the Authotization Rules it has enabled Allow All Users and A [More]
please helpWithout access to the device, the only thing you can do is rely on the last backup you did of the device. You will not be able to get anything from it now.Read other 2 answers [More]
your on-line tech support is ALWAYS CLOSED (very disgusting) == This happened == Every time Firefox opened == about a monthHello Judy. First of all, I will let you know that Firefox's support is community driven. As is Firefox as a whole, to be fair. [More]
Hi - My i-pod seems to have died and will not charge - any clues - thanksHave you worked through all the troubleshooting here? iPod's battery doesn't charge This article might come in handy as well. iPod won't turn on Keep in mind that a completely d [More]
i have two questions 1.  why does tcodes of CIN starts with J  like J1id, J1is  is there any specific reason? 2. secondly  by mistake on  our plant we had made a excise invoice in which we had a placesspayable of rs 17 lakhs which was actually not pa [More]