I\'m pretty new in the ASP .NET MVC world. Maybe, that\'s the reason I can\'t explain to myself the cause of what is, for me, an annoying problem.
I have one class w
So, if I understand correctly, you are adding an empty List
to the context and then trying to retrieve it.
I guess you have to think about how the context will track and query entities that are in its context. This is usually done by the Key
of the entity. In your example, you have not given the entity a Key
, therefore, the context has no handle on the entity.
Therefore, when you query, the context doesn't find an object and returns null.
If you want to initialize a new entity, I would recommend to give it at least a Key
(usually the Id property), and then select by that key when you lookup later.
Hope this helps.