With Entity Framework master detail structure can't savechanges issue

647 Views Asked by At

I am working on windows form based application. I'm working with Entity Framework 6.0 on Visual Stduio 2012. I implemented some windows forms of course.For now i have only 1 master detailed form. Here is screen of that master detailed form enter image description here

First of all i give more detail about my project. As u can see on the left side of print screen there are names like Depolar,Siparisler,SiparislerDetay... In SiparisGirisiForm field like SiparisNo,Siparis Tarihi,... are coming from Siparisler in SampleDataSet. I took these fields from Siparisler that exist in SampleDataSet. And for my Siparisler's detail, i choose SiparislerDetay in Siparisler and SiparislerDetay is GridControl. To here everything is ok when i run my program and open SiparisGirisiForm i entered some values and clicked to Kaydet barMenuButton(This button makes save to database basically) on the top left side of the screen i am getting this error: column of Siparis_Id doesn't allow null values.enter image description here

In database and EntityModel structure its definetly true. I must not save a detail info without any relation with its master. column Siparis_Id is foreign key in SiparislerDetay class and related Siparisler's Id column. I cant save this values to database. For 2 days i am counting on my place. My project doesn't move on. I must solve this problem. Is there anyone to help to this one? Thanks...

1

There are 1 best solutions below

1
On BEST ANSWER

Set entity framework code generation strategy from None to Default, on model designer screen. And you see, it works.