What I'm looking to do is set a Foreign Key object in an EF entity via FluentHtml. I have an entity of Foo with a reference to the object Bar via Foo.Bar. What I am trying to do is set the value of Bar in my view form. My models contains a collection of all Bars via Model.Bars. In my view I'm simply using <%= this.Select(m => m.Foo.Bar).Options(Model.Bars) %>
but the model state claims it is not valid. The dropdown is properly filled with Bar ids and it all looks valid. Is there some special magic I need for setting EF entity reference properties in my forms?
I just moved over from Linq2SQL where I was simply using Select(m => m.Foo.BarId) as you could have the key reference mapped as well as the object. However, Entity Framework does not allow this.