entity framework - The INSERT statement conflicted with the FOREIGN KEY constraint . The statement has been terminated -


the insert statement conflicted foreign key constraint "fk_t_orderdetails_t_selectionlist". conflict occurred in database "albumportal", table "dbo.t_selectionlist", column 'id'.

i new asp.net mvc ef code-first approach, error when trying save data t_orderdetails controller.

in t_orderdetails table 'selectionlist_id' foreign key table dbo.t_selectionlist. defined

public virtual t_selectionlist t_selectionlist { get; set; } 

in 't_orderdetails' ,

[system.diagnostics.codeanalysis.suppressmessage("microsoft.usage", "ca2227:collectionpropertiesshouldbereadonly")] public virtual icollection<t_orderdetails> t_orderdetails { get; set; } 

in 't_selectionlist'.

modelbuilder.entity<t_selectionlist>()                 .hasmany(e => e.t_orderdetails)                 .withoptional(e => e.t_selectionlist)                 .hasforeignkey(e => e.selectionlist_id);  

is defined. don't understand why error getting.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -