Menu
  • HOME
  • TAGS

EF 6, How to delete an Entity without enforcing cascade delete and satisfying Foreign Key restraints

entity-framework,cascading-deletes

Make your FK constraint optional. modelBuilder.Entity<Client>() .HasOptional(r => r.Country) .WithMany() .WillCascadeOnDelete(false); That way it is possible to have a nullable Foreign key. Your FK will only be set to null if, and only if, your child object is also loaded in EF. So here you have to include your Country...

How to check if deletion is caused by CASCADE in PostgreSQL trigger

postgresql,plpgsql,cascading-deletes,postgresql-9.3

I can't think of a built-in way to check that. You could instead check for existence of the master row in the master table ... IF EXISTS ( SELECT 1 FROM master_table m WHERE m.master_id = OLD.master_id) THEN -- run checks END IF; If it's a cascading delete the master...

delete the output of a join (record in multipe tables)

sql,postgresql,join,cloudfoundry,cascading-deletes

You may use WITH construction. with _deleted_service_instances as ( delete from service_instances where guid = 'daf67426-129b-4010-832c-692bcfe98f62' returning id ) , _deleted_service_instance_operations as ( delete from service_instance_operations op using _deleted_service_instances i where op.service_instance_id = i.id ) , _deleted_service_bindings as ( delete from service_bindings b using _deleted_service_instances i where b.service_instance_id = i.id...

Laravel 4.2 how to determine if model is soft delete or force delete

laravel,cascading-deletes,soft-delete

The model has a property forceDeleting. Which will either be true or false: if($invoice->forceDeleting){ //do in case of force delete } else { //do in case of soft delete } Note that this property is only available when using the SoftDeletingTrait. So be careful to use this in some kind...

Delete an item from many-to-many relationship

nhibernate,fluent-nhibernate,many-to-many,nhibernate-mapping,cascading-deletes

The answer is (I am really sure) here: NHibernate Deleted object would be re-saved by cascade Let me re-phrase that for your case, what could happen: we remove an GrupoArquivo from ArquivoRetorno.GrupoModulos collection. During that transaction, unit of work, we also tuch and therefore load the GrupoModulo GrupoModulo gets initiated...