Currently i am trying tomake a EF database and I wunder why and how to get this is "NULL" away from my table


I am currently trying to make a EF system with a few relations/FKs.

My classes looklik this : I have an artikel class, a Location class and a prognoseclass that look like following: enter image description here

enter image description here

enter image description here

After i run my "Package manager comandline" with a "fresh database" i get with seeded data Like this:

enter image description here

Now the question is : why is there a "Entry" Location_LocationId that has a NULL valll?

How can one get this away or shall it be there:??

If I havent provided enough data please let me know.

My system is working as i want to have it but i am desperate trying to "optimize" it and trying to get questions like this cleared out.

answered question

1 Answer


Try to use attribute ForeignKey.


before "LocationId" property in "Prognose" class

You can read this tutorial If you want to make one to one relations in EF.

posted this

Have an answer?


Please login first before posting an answer.