Table 'XXX.dbo.aspnetusers' 不存在,迁移 VS-Mysql

Table 'XXX.dbo.aspnetusers' doesn't exist, migrations VS-Mysql

我在 ApplicationUser 中添加了一些属性,现在我想删除这些属性,但是我有这个:

MySql.Data.MySqlClient.MySqlException (0x80004005): Table 'intranetproto.dbo.aspnetusers' 不存在。

这是我要删除的属性:

 public class ApplicationUser : IdentityUser
{
    public string Email { get; set; }
    [Required]
    public string FirstName { get; set; }
    [Required]
    public string LastName { get; set; }
    public int SignatureId { get; set; }

    public virtual Signature Signature { get; set; }
    public virtual string FullName
    {

        get
        {
            return FirstName + " " + LastName;
        }

    }

}

这是我的身份模型(没有一些属性)

public class ApplicationUser : IdentityUser
{
    public string Email { get; set; }


}

 [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("DefaultConnection")
    {
    }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Model> Models { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Quote> Quotes { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Customer> Customers { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Participant> Participants { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.File> Files { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Family> Families { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Procedure> Procedures { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Vendor> Vendors { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Log> Logs { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Signature> Signatures { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Receipt> Receipt { get; set; }

    public System.Data.Entity.DbSet<LocalIdentity.Models.Department> Departments { get; set; }


}

这是我的迁移:

namespace LocalIdentity.Migrations
{
    using System;
    using System.Data.Entity.Migrations;

    public partial class SignatureIdInUSerDeleted : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.aspnetusers", "SignatureId", "dbo.Signatures");
            DropIndex("dbo.aspnetusers", new[] { "SignatureId" });
            DropColumn("dbo.aspnetusers", "FirstName");
            DropColumn("dbo.aspnetusers", "LastName");
            DropColumn("dbo.aspnetusers", "SignatureId");
        }

        public override void Down()
        {
            AddColumn("dbo.aspnetusers", "SignatureId", c => c.Int());
            AddColumn("dbo.aspnetusers", "LastName", c => c.String(unicode: false));
            AddColumn("dbo.aspnetusers", "FirstName", c => c.String(unicode: false));
            CreateIndex("dbo.aspnetusers", "SignatureId");
            AddForeignKey("dbo.aspnetusers", "SignatureId", "dbo.Signatures", "Id", cascadeDelete: true);
        }
    }
}

我不知道为什么会出现此错误,如果我可以添加我应该可以删除。

我终于弄明白了,迁移的问题是前缀"dbo",我把它们都删除了,它起作用了,我找到了答案here,我更改了我的配置[=19] =] 对此:

public Configuration()
    {
        AutomaticMigrationsEnabled = true;
        SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator());
        CodeGenerator = new MySql.Data.Entity.MySqlMigrationCodeGenerator(); //this line was missing, so now the migrations does not contains the prefix "dbo"

    }

现在迁移自动生成,没有前缀 "dbo"

  public override void Up()
    {
        DropForeignKey("UserDatas", "UserId", "AspNetUsers");
        DropIndex("UserDatas", new[] { "UserId" });
        AlterColumn("UserDatas", "UserId", c => c.String(nullable: false, maxLength: 128, unicode: false, storeType: "nvarchar"));
        AlterColumn("UserDatas", "FirstName", c => c.String(nullable: false, unicode: false));
        AlterColumn("UserDatas", "LastName", c => c.String(nullable: false, unicode: false));
        AlterColumn("UserDatas", "Title", c => c.String(nullable: false, unicode: false));
        CreateIndex("UserDatas", "UserId");
        AddForeignKey("UserDatas", "UserId", "AspNetUsers", "Id", cascadeDelete: true);
    }