1
我增加了一些特性到ApplicationUser遷移,現在我想刪除這些屬性,但我有這樣的:表「XXX.dbo.aspnetusers」不存在,VS-mysql的
MySql.Data.MySqlClient.MySqlException (0x80004005):表'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);
}
}
}
我不不知道爲什麼我得到這個錯誤,如果我可以添加,我應該可以刪除。
您在更新數據庫步驟中獲得了這個結果嗎?嘗試編寫腳本,以便可以看到生成的SQL。通常我懷疑連接字符串問題。 –
謝謝,但我沒有連接字符串的問題,'因爲我可以添加表,添加列,但是,問題是當我想「改變」表,這個問題是與MySql,在Ms-Sql工作正常。 –