ASP.NET 4.3 Scaffolding: Add Controller vs Add View - different behavior?

I am trying to dig into ASP.NET MVC 3, using the standard tutorials in the web, and I encounter a strage problem.

Currently, I am following the samples in a book, using a "Movie" class with movie genres stored in a separate entity, connected with a foreign key (okay, I am from Germany, so my class is named in German). I show only the relevant properties here. It's a database first approach using DbContext, my model was created from the edmx by using the EF 4.x DbContext Generator and the edmx was automatically created from the data base.

public partial class Film
    public Film() { }

    public int ID { get; set; }
    public string Titel { get; set; }
    public int GenreID { get; set; }
    public virtual Genre Genre { get; set; }

public partial class Genre
    public Genre() { }
    public int GenreID { get; set; }
    public string Name { get; set; }

When I create a new Controller with CRUD Views for the Film class, using a DBContext that provides a DBSet, I get an Edit view that uses a DropdownList to edit GenreID, labelled "Genre". Fine. That's what I want.

But then, I tried to create another edit view, separately. So I right-clicked into my Edit Action-Method, selected "Add View", called it "Edit2", used Film as model and "Edit" as scaffold template. In this view, I got a simple "EditorFor(m->m.GenreID)", labelled GenreID. That's not what I want.

Of course, I can change that manually. Of course, I can download a slew of scaffolding tools that claim to do better.

But I want to understand if this is a bug in the EF templates, or if my model is built wrong so that Genre / GenreID gets confused. When I create everything at once, scaffolding creates a DropDown, so there must be "just" some detail that's missing.


You will need to call your Action in your controller "Edit2".

Need Your Help

How to send mail with attachment

php forms attachment

Using form on web site, I want to upload attachment first and send it to arbitary email address. I've tried to use phpmailer, but I've never managed to attach file just browsing it, only directly:

Replace accents from lists of foreign words

list localization

Do you know if there are any linux programs out there to remove accents from lists of foreign words (in utf8)? Like Spanish, Czech, French. For instance: