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

ios - Is 'init' forbidden as *part* of a variable name? -

file - Python: AttributeError: 'str' object has no attribute 'readlines' -

c# - Get the Class name in a class with atribute inside a attribute method -