title: Unable to retrieve metadata for models when adding a controller
body: <p>I'm learning ASP.NET MVC 5 on "Visual Studio 2015 Community" as a newbie. I'm trying to add a controller with Entity Framework models.</p>
  
  <p><a href="https://i.stack.imgur.com/V3OxH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V3OxH.png" alt="enter image description here"></a></p>
  
  <p>And an error appears. I'm so confused.</p>
  
  <p><a href="https://i.stack.imgur.com/XFaMs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XFaMs.png" alt="enter image description here"></a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  using System.ComponentModel.DataAnnotations.Schema;
  using System.Linq;
  using System.Web;
  
  namespace TwiApp.Models
  {
      public class Twilio
      {
          [Key]
          public int id { get; set; }
          public string userId { get; set; }
          public string sid { get; set; }
          public string authToken { get; set; }
          public string fromNumber { get; set; }
          public string toNumber { get; set; }
          public bool status { get; set; }
          [ForeignKey("userId")]
          public virtual ApplicationUser twi_appuser_ref { get; set; }
      }
  }
  </code></pre>
  
  <p>My connection string to SQL Server 2014:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=TwiAppDB;Integrated Security=True"
    providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>And finally, my databasecontext file:</p>
  
  <pre><code>using Microsoft.AspNet.Identity.EntityFramework;
  using System;
  using System.Collections.Generic;
  using System.Data.Entity;
  using System.Data.Entity.ModelConfiguration.Conventions;
  using System.Linq;
  using System.Web;
  using TwiApp.Models;
  
  namespace TwiApp.DAL
  {
      public class DatabaseContext : IdentityDbContext&lt;ApplicationUser&gt;
      {
          public DatabaseContext() : base("DefaultConnection", throwIfV1Schema: false)
          {
          }
  
          public DbSet&lt;Twilio&gt; Twilio_Db { get; set; }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {          
              modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
              base.OnModelCreating(modelBuilder);
          }
  
          public static DatabaseContext Create()
          {
              return new DatabaseContext();
          }
      }
  }
  </code></pre>
  
  <p>What I have tried so far:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/14125892/asp-net-mvc-ef-code-first-error-unable-to-retrieve-metadata-for-model">ASP.NET MVC/EF Code First error: Unable to retrieve metadata for model</a></li>
  <li><a href="https://stackoverflow.com/questions/17525905/unable-to-retrieve-metadata-mvc-application">Unable to retrieve metadata - MVC application</a></li>
  <li><a href="https://stackoverflow.com/questions/12546545/unable-to-retrieve-metadata">Unable to Retrieve Metadata</a></li>
  <li><a href="https://stackoverflow.com/questions/12165185/mvc4-scaffolding-add-controller-gives-error-unable-to-retrieve-metadata">MVC4 Scaffolding Add Controller gives error &quot;Unable to retrieve metadata...&quot;</a></li>
  <li><a href="https://stackoverflow.com/questions/35542363/cannot-create-controller-with-entity-framework-unable-to-retrieve-metadata-for">Cannot create controller with Entity framework - Unable to retrieve metadata for &#39; &#39;</a></li>
  </ol>
  
  <p>Any answers will be apprecited. Thank you.</p>