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
We are trying to improve the performance of our system and have noticed that the number of columns in our select statements has a dramatic, non-linear effect on the performance we see. For a particular query (with a single record returned) retrieving [More]
I have been using Photoshop and Lightroom for years, purchasing upgrades. If I join CC do I have to pay the same as someone new to PS and Lightroom?Asked and answered in another thread Photoshop and Lightroom old timersRead other 2 answers [More]
Hi We are running EP 6.0 SP7, we created some BW reports as links in the KM of the Portal. Now we want to set up an index over the content of this Report which resides on the BW 3.5 System. Can we do that? Is that possible and how? thanks MuratHello [More]
I'd like to return a none zero exit code after a normal graceful shutdown. My end task is to be able to send a restart event to a number of machines running my application that will gracefully shutdown and inform the shell script that started it that [More]
I am loading data from a flat file to a DSO. One of the columns in the flat file is data type CHAR with a length of two. The data values will be either 01, 02 or 03. When I load the data, the leading zeroes are dropped. Thus, I see 1, 2 and 3 in my D [More]
how do you download more photo booth effects on your macbook pro with mac lion version? Effects such as sharpen, film stock, etc.There should be a download link on the extra special effects Photo Booth website.  If not, do a Google search for a site [More]
Just got an email back from Sony regarding my question to them on when will their AU version of their Oxford plugs be available. Below is their response to me. Hi Steven, Very close. We are in the middle of a beta phase for AU versions of our EQ, Lim [More]
Is there way of seleceting many podcasts and using the get command for all of them at once? iPod   Windows XP  Refresh works once one has subcribed and "Got" all the episodes that one wants. It does not apply when one first subscribes. At that p [More]
Hi, Can u please give an idea about RF Screen. Am new to it. Regards, Vijay.hi good Most corporations who implement an ERP system are confronted with the issue of how to simplify and streamline the logistics process utilizing radio frequency (RF) tec [More]
Anything i try related to firefix gets "Your computer must be restarted to complete a previous upgrade of Firefox" I have tried rebooting no luck, i have tired uninstalling from add remove programs or installing 4.0 over it. At the time I was tr [More]