title: Sequence contains no matching element scaffolding visual studio 2015
body: <p>I am using code first database first (MYSQL, ENTITYFRAMEWORK 6, VISUAL STUDIO 2015)
  I am trying to add a controller using scaffolding from the model generated</p>
  
  <p>But i get "there was an error running the selected code generator sequence contains no elements, Unable to retrieve metadata for ...; Sequence contains no matching element";</p>
  
  <p>The model were generated successifully from the database but adding a controller for the specified model using scaffolding returns error.</p>
  
  <p><strong><em>DataContex</em></strong> </p>
  
  <pre><code> using System;
  using System.Data.Entity;
  using System.ComponentModel.DataAnnotations.Schema;
  using System.Linq;
  
  public partial class Model1 : DbContext
  {
      public Model1()
          : base("name=Model1")
      {
      }
  
      public virtual DbSet&lt;actor&gt; actors { get; set; }
      public virtual DbSet&lt;address&gt; addresses { get; set; }
      public virtual DbSet&lt;category&gt; categories { get; set; }
      public virtual DbSet&lt;city&gt; cities { get; set; }
      public virtual DbSet&lt;country&gt; countries { get; set; }
      public virtual DbSet&lt;customer&gt; customers { get; set; }
      public virtual DbSet&lt;film&gt; films { get; set; }
      public virtual DbSet&lt;film_actor&gt; film_actor { get; set; }
      public virtual DbSet&lt;film_category&gt; film_category { get; set; }
      public virtual DbSet&lt;film_text&gt; film_text { get; set; }
      public virtual DbSet&lt;inventory&gt; inventories { get; set; }
      public virtual DbSet&lt;language&gt; languages { get; set; }
      public virtual DbSet&lt;payment&gt; payments { get; set; }
      public virtual DbSet&lt;rental&gt; rentals { get; set; }
      public virtual DbSet&lt;staff&gt; staffs { get; set; }
      public virtual DbSet&lt;store&gt; stores { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;actor&gt;()
              .Property(e =&gt; e.first_name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;actor&gt;()
              .Property(e =&gt; e.last_name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;actor&gt;()
              .HasMany(e =&gt; e.film_actor)
              .WithRequired(e =&gt; e.actor)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .Property(e =&gt; e.address1)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .Property(e =&gt; e.address2)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .Property(e =&gt; e.district)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .Property(e =&gt; e.postal_code)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .Property(e =&gt; e.phone)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .HasMany(e =&gt; e.customers)
              .WithRequired(e =&gt; e.address)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .HasMany(e =&gt; e.staffs)
              .WithRequired(e =&gt; e.address)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;address&gt;()
              .HasMany(e =&gt; e.stores)
              .WithRequired(e =&gt; e.address)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;category&gt;()
              .Property(e =&gt; e.name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;category&gt;()
              .HasMany(e =&gt; e.film_category)
              .WithRequired(e =&gt; e.category)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;city&gt;()
              .Property(e =&gt; e.city1)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;city&gt;()
              .HasMany(e =&gt; e.addresses)
              .WithRequired(e =&gt; e.city)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;country&gt;()
              .Property(e =&gt; e.country1)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;country&gt;()
              .HasMany(e =&gt; e.cities)
              .WithRequired(e =&gt; e.country)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;customer&gt;()
              .Property(e =&gt; e.first_name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;customer&gt;()
              .Property(e =&gt; e.last_name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;customer&gt;()
              .Property(e =&gt; e.email)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;customer&gt;()
              .HasMany(e =&gt; e.payments)
              .WithRequired(e =&gt; e.customer)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;customer&gt;()
              .HasMany(e =&gt; e.rentals)
              .WithRequired(e =&gt; e.customer)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;film&gt;()
              .Property(e =&gt; e.title)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;film&gt;()
              .Property(e =&gt; e.description)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;film&gt;()
              .Property(e =&gt; e.rating)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;film&gt;()
              .Property(e =&gt; e.special_features)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;film&gt;()
              .HasMany(e =&gt; e.film_actor)
              .WithRequired(e =&gt; e.film)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;film&gt;()
              .HasMany(e =&gt; e.film_category)
              .WithRequired(e =&gt; e.film)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;film&gt;()
              .HasMany(e =&gt; e.inventories)
              .WithRequired(e =&gt; e.film)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;film_text&gt;()
              .Property(e =&gt; e.title)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;film_text&gt;()
              .Property(e =&gt; e.description)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;inventory&gt;()
              .HasMany(e =&gt; e.rentals)
              .WithRequired(e =&gt; e.inventory)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;language&gt;()
              .Property(e =&gt; e.name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;language&gt;()
              .HasMany(e =&gt; e.films)
              .WithRequired(e =&gt; e.language)
              .HasForeignKey(e =&gt; e.language_id)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;language&gt;()
              .HasMany(e =&gt; e.films1)
              .WithOptional(e =&gt; e.language1)
              .HasForeignKey(e =&gt; e.original_language_id);
  
          modelBuilder.Entity&lt;staff&gt;()
              .Property(e =&gt; e.first_name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;staff&gt;()
              .Property(e =&gt; e.last_name)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;staff&gt;()
              .Property(e =&gt; e.email)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;staff&gt;()
              .Property(e =&gt; e.username)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;staff&gt;()
              .Property(e =&gt; e.password)
              .IsUnicode(false);
  
          modelBuilder.Entity&lt;staff&gt;()
              .HasMany(e =&gt; e.payments)
              .WithRequired(e =&gt; e.staff)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;staff&gt;()
              .HasMany(e =&gt; e.rentals)
              .WithRequired(e =&gt; e.staff)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;staff&gt;()
              .HasMany(e =&gt; e.stores)
              .WithRequired(e =&gt; e.staff)
              .HasForeignKey(e =&gt; e.manager_staff_id)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;store&gt;()
              .HasMany(e =&gt; e.customers)
              .WithRequired(e =&gt; e.store)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;store&gt;()
              .HasMany(e =&gt; e.inventories)
              .WithRequired(e =&gt; e.store)
              .WillCascadeOnDelete(false);
  
          modelBuilder.Entity&lt;store&gt;()
              .HasMany(e =&gt; e.staffs)
              .WithRequired(e =&gt; e.store)
              .HasForeignKey(e =&gt; e.store_id)
              .WillCascadeOnDelete(false);
      }
  }
  </code></pre>
  
  <p><strong><em>My model</em></strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  using System.ComponentModel.DataAnnotations.Schema;
  using System.Data.Entity.Spatial;
  
  [Table("sakila.actor")]
  public partial class actor
  {
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
      public actor()
      {
          film_actor = new HashSet&lt;film_actor&gt;();
      }
  
      [Key]
      [Column(TypeName = "usmallint")]
      public int actor_id { get; set; }
  
      [Required]
      [StringLength(45)]
      public string first_name { get; set; }
  
      [Required]
      [StringLength(45)]
      public string last_name { get; set; }
  
      [Column(TypeName = "timestamp")]
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public DateTime last_update { get; set; }
  
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
      public virtual ICollection&lt;film_actor&gt; film_actor { get; set; }
  }
  </code></pre>
  
  <p>Can anyone help solve this? </p>