c# - EF Cascade delete when child property maps to SQL View -


we have following model:

public class company {     public int id {get; set; }     public string name {get; set; }     public companyrepresentative companyrepresentatives {get; set; } }  public class companyrepresentative {     public int id {get; set; }     public string representativenames {get; set; } } 

companyrepresentative sql view , mapped using fluent api:

modelbuilder.entity<company>()     .hasoptional(q => q.companyrepresentatives)     .withoptionalprincipal()     .map(q => q.mapkey("companyid")); 

the problem when deleting company ef attempting update companyrepresentative setting companyid null fails because view.

we have tried changing mapping to:

modelbuilder.entity<company>()     .hasoptional(q => q.companyrepresentatives)     .withoptionalprincipal()     .map(q => q.mapkey("companyid"))     .willcascadeondelete(false); 

...which had no effect.

is there way tell ef not try , update property when deleting?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -