title: Cannot find the object "dbo.course" because it does not exist or you do not have permissions
body: <p>I am developing an ASP.NET MVC5 Web Application. I am using Entity Framework 6 for my data storage needs. I am using the code first feature of it with migrations enabled. automatic migrating set to false.</p>
  
  <p>I have two tables that I'm trying to change. The first Table is called course and this is it's model. </p>
  
  <pre><code>public class course
  {
      [Key]
      public int courseID { get; set; }
      public int categoryID { get; set; }
      public int PaymentOptionsID { get; set; }
      [Required]
      [DisplayName("Course Code")]
      public string courseCode { get; set; }
      [Required]
      [DisplayName("Course Name")]
      public string courseName { get; set; }
      [Required]
      [DataType(DataType.Currency)]
      public decimal price { get; set; }
      [DataType(DataType.MultilineText)]
      [DisplayName("Course Description")]
      [StringLength(255, ErrorMessage = "Only a maximum of 255 characters are                                     allowed")]
      public string courseDescription { get; set; }
      [Required]
      [DisplayName("Study Material")]
      public string courseIncludes { get; set; }
      public string courseInfoUrl { get; set; }
  
      public virtual ICollection&lt;enrollment&gt; enrollment { get; set; }
      public virtual courseCategory courseCategory { get; set; }
      public virtual PaymentOptions PaymentOptions { get; set; }
  }
  </code></pre>
  
  <p>The second table's name is paymentOptions and here is it's model.    </p>
  
  <pre><code>public class PaymentOptions
  {
      [Key]
      public int PaymentOptionsID { get; set; }
      public int courseID { get; set; }
      [DisplayName("Payment Options")]
      public string paymentOption {get; set; }
  }
  </code></pre>
  
  <p>I have 5 migrations that I've added and they worked fine. Now I'm trying to add the sixth one where I am trying to make the following changes to the tables    </p>
  
  <pre><code>public class course
  {
      [Key]
      public int courseID { get; set; }
      public int categoryID { get; set; }
      public int PaymentOptionsID { get; set; }
      [Required]
      [DisplayName("Course Code")]
      public string courseCode { get; set; }
      [Required]
      [DisplayName("Course Name")]
      public string courseName { get; set; }
      [Required]
      [DataType(DataType.Currency)]
      public decimal price { get; set; }
      [Required]
      [DisplayName("Course Includes")]
      public string courseIncludes { get; set; }
      public string courseInfoUrl { get; set; }
  
      public virtual ICollection&lt;enrollment&gt; enrollment { get; set; }
      public virtual courseCategory courseCategory { get; set; }
      public virtual ICollection&lt;PaymentOptions&gt; PaymentOptions { get; set; }
  }    
  
  public class PaymentOptions
  {
      [Key]
      public int PaymentOptionsID { get; set; }
      public int courseID { get; set; }
      [DisplayName("Payment Options")]
      public string paymentOption {get; set; }
  
      public virtual ICollection&lt;course&gt; course { get; set; }
  }
  </code></pre>
  
  <p>When I add the Migration It works fine but as soon as I hit the update-database command all of the sudden I get this error</p>
  
  <p>"Cannot find the object "dbo.course" because it does not exist or you do not have permissions."</p>
  
  <p>This is what the migration looks like.    </p>
  
  <pre><code>public partial class AddPaymentOptionsagain : DbMigration
  {
      public override void Up()
      {
          RenameTable(name: "dbo.course", newName: "PaymentOptionscourse");
          DropForeignKey("dbo.course", "PaymentOptions_PaymentOptionsID", "dbo.PaymentOptions");
          DropIndex("dbo.course", new[] { "PaymentOptions_PaymentOptionsID" });
          AddColumn("dbo.course", "PaymentOptionsID", c =&gt; c.Int(nullable: false));
          CreateIndex("dbo.PaymentOptionscourse", "PaymentOptions_PaymentOptionsID");
          CreateIndex("dbo.PaymentOptionscourse", "course_courseID");
          AddForeignKey("dbo.PaymentOptionscourse", "PaymentOptions_PaymentOptionsID", "dbo.PaymentOptions", "PaymentOptionsID", cascadeDelete: true);
          AddForeignKey("dbo.PaymentOptionscourse", "course_courseID", "dbo.course", "courseID", cascadeDelete: true);
          DropColumn("dbo.course", "courseDescription");
          DropColumn("dbo.course", "PaymentOptions_PaymentOptionsID");
      }
  
      public override void Down()
      {
          AddColumn("dbo.course", "PaymentOptions_PaymentOptionsID", c =&gt; c.Int());
          AddColumn("dbo.course", "courseDescription", c =&gt; c.String(maxLength: 255));
          DropForeignKey("dbo.PaymentOptionscourse", "course_courseID", "dbo.course");
          DropForeignKey("dbo.PaymentOptionscourse", "PaymentOptions_PaymentOptionsID", "dbo.PaymentOptions");
          DropIndex("dbo.PaymentOptionscourse", new[] { "course_courseID" });
          DropIndex("dbo.PaymentOptionscourse", new[] { "PaymentOptions_PaymentOptionsID" });
          DropColumn("dbo.course", "PaymentOptionsID");
          CreateIndex("dbo.course", "PaymentOptions_PaymentOptionsID");
          AddForeignKey("dbo.course", "PaymentOptions_PaymentOptionsID", "dbo.PaymentOptions", "PaymentOptionsID");
          RenameTable(name: "dbo.PaymentOptionscourse", newName: "course");
      }
  }
  </code></pre>
  
  <p>I have read all the questions on stackoverflow, <a href="http://forums.asp.net" rel="nofollow">http://forums.asp.net</a>, msdn.microsoft.com › SQL Server and I still can't seem to figure out why this is happening and what I need to do to fix it.</p>
  
  <p>Any help would be much appreciated. Thanks in advance </p>