http://blog.stevensanderson.com/2011/01/28/mvcscaffolding-one-to-many-relationships/
Defining more complex relations between model classes
mvc
Depending on what data access technology you’re using, there may be many possible ways of defining how models are related together. If you’re using EF Code First, for example, you could be using its fluent configuration interface, which means writing code with statements like 「someEntity.HasOptional(x => x.Players).WithForeignKey(x => x.TeamId).CascadeDelete()」 and so on.app
MvcScaffolding doesn’t know about all of that. For one thing, fluent configuration exists only at runtime (and scaffolding works at design time), and for another, you might be using any data access technology with its own configuration system. You can still use fluent configuration or anything else; just don’t expect scaffolding to know about it.ide
Instead, MvcScaffolding supports two simple and broadly applicable conventions that will work fine with most data access technologies, including EF. spa
[ForeignKey("ManagerId")] public virtual Person Manager { get; set; }