entity framework - ASP.NET Models - Best Empty Object Creation? -
so if want add artist website, , create model holds , additional details like:
namespace supermusic.models { public artist newartist { get; set; } public ienumerable<recordcompanies> recordcompanies { { //some code populate possible record companies } }
now can have view create new artist , model populate drop down of record companies artist can associated with.
but in controller, have define "new artist". believe there 2 ways this:
newartistmodel.newartist = context.artist.create(); newartistmodel.newartist = new artist();
is 1 of these more correct other? or there difference in code , 1 of these incorrect?
thanks again answer noob questions!
the first option newartistmodel.newartist = context.artist.create();
correct method creating new instances context
create entity framework aware proxy objects.
proxy objects provide full support navigation properties etc.
there's more complete answer here
Comments
Post a Comment