uniqueidentifier 与 bigint entity framework c# 代码不兼容
uniqueidentifier is incompatible with bigint entity framework c# code first
我的 EF 代码中有这个实体 First
public class Equipment
{
public Int64 Id { set; get; }
public string Name { set; get; }
public string Model { set; get; }
public string Factory { set; get; }
public DateTime SubmitDateTime { set; get; }
public GUID OrganizationId { set; get; }
}
我改成了
public class Equipment
{
public Int64 Id { set; get; }
public string Name { set; get; }
public string Model { set; get; }
public string Factory { set; get; }
public DateTime SubmitDateTime { set; get; }
public Int64 OrganizationId { set; get; }
}
但是在 运行 之后我得到这个错误:
An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Operand type clash: uniqueidentifier is incompatible with bigint
这里是我的迁移方法:
public class MigrationsConfiguration : DbMigrationsConfiguration<DataContext>
{
public MigrationsConfiguration()
{
this.AutomaticMigrationDataLossAllowed = true;
this.AutomaticMigrationsEnabled = true;
}
}
我的数据库中有很多数据。所以我无法删除它来生成它again.so我该如何解决这个错误?
通过三个步骤我改变了它:
第一的
我在我的实体中添加了另一列
public GUID OrganizationId { set; get; }
public int64 OrganizationId2 { set; get; }
秒
我删除了实体中的 guid 列
public int64 OrganizationId2 { set; get; }
最后一步
最后我重命名了我的新专栏
public int64 OrganizationId { set; get; }
我的 EF 代码中有这个实体 First
public class Equipment
{
public Int64 Id { set; get; }
public string Name { set; get; }
public string Model { set; get; }
public string Factory { set; get; }
public DateTime SubmitDateTime { set; get; }
public GUID OrganizationId { set; get; }
}
我改成了
public class Equipment
{
public Int64 Id { set; get; }
public string Name { set; get; }
public string Model { set; get; }
public string Factory { set; get; }
public DateTime SubmitDateTime { set; get; }
public Int64 OrganizationId { set; get; }
}
但是在 运行 之后我得到这个错误:
An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Operand type clash: uniqueidentifier is incompatible with bigint
这里是我的迁移方法:
public class MigrationsConfiguration : DbMigrationsConfiguration<DataContext>
{
public MigrationsConfiguration()
{
this.AutomaticMigrationDataLossAllowed = true;
this.AutomaticMigrationsEnabled = true;
}
}
我的数据库中有很多数据。所以我无法删除它来生成它again.so我该如何解决这个错误?
通过三个步骤我改变了它: 第一的 我在我的实体中添加了另一列
public GUID OrganizationId { set; get; }
public int64 OrganizationId2 { set; get; }
秒 我删除了实体中的 guid 列
public int64 OrganizationId2 { set; get; }
最后一步 最后我重命名了我的新专栏
public int64 OrganizationId { set; get; }