类型 'MS.Internal.TextFormatting.GetObjectHandlerInfo' 和类型 'MS.Internal.PtsHost.UnsafeNativeMethods.PTS+GetObjectHandlerInfo'
The type 'MS.Internal.TextFormatting.GetObjectHandlerInfo' and the type 'MS.Internal.PtsHost.UnsafeNativeMethods.PTS+GetObjectHandlerInfo'
当我使用添加迁移测试时
告诉我这个错误:
The type 'MS.Internal.TextFormatting.GetObjectHandlerInfo' and the type 'MS.Internal.PtsHost.UnsafeNativeMethods.PTS+GetObjectHandlerInfo' both have the same simple name of 'GetObjectHandlerInfo' and so cannot be used in the same model. All types in a given model must have unique simple names. Use 'NotMappedAttribute' or call Ignore in the Code First fluent API to explicitly exclude a property or type from the model.
这是数据库上下文:
public virtual DbSet<Tbl_User> Tbl_User { get; set; }
public virtual DbSet<Tbl_Customer> Tbl_Customer { get; set; }
public virtual DbSet<Tbl_Product> Tbl_Product { get; set; }
我该如何解决这个问题?
**编辑**
public partial class AnbarDB : DbContext
{
public AnbarDB()
: base("name=AnbarDB1")
{
}
public virtual DbSet<Tbl_User> Tbl_User { get; set; }
public virtual DbSet<Tbl_Customer> Tbl_Customer { get; set; }
public virtual DbSet<Tbl_Product> Tbl_Products { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
}
}
.
这个 class 是问题,当我删除这个 class 时,迁移工作
public partial class Tbl_Product
{
[Key]
public int ProductId { get; set; }
[StringLength(100)]
public string ProductName { get; set; }
public string ProductDescription { get; set; }
public long ProductLastFee { get; set; }
public int ProductLastSuply { get; set; }
public Image ProductImage { get; set; }
public DateTime DateReg { get; set; }
[ForeignKey("UserID")]
public virtual Tbl_User Users { get; set; }
public int UserID { get; set; }
}
您不能拥有 属性 ProductImage
Image
类型的 EF 实体。你将不得不存储图像,让我们说 byte[] array.
当我使用添加迁移测试时
告诉我这个错误:
The type 'MS.Internal.TextFormatting.GetObjectHandlerInfo' and the type 'MS.Internal.PtsHost.UnsafeNativeMethods.PTS+GetObjectHandlerInfo' both have the same simple name of 'GetObjectHandlerInfo' and so cannot be used in the same model. All types in a given model must have unique simple names. Use 'NotMappedAttribute' or call Ignore in the Code First fluent API to explicitly exclude a property or type from the model.
这是数据库上下文:
public virtual DbSet<Tbl_User> Tbl_User { get; set; }
public virtual DbSet<Tbl_Customer> Tbl_Customer { get; set; }
public virtual DbSet<Tbl_Product> Tbl_Product { get; set; }
我该如何解决这个问题?
**编辑**
public partial class AnbarDB : DbContext
{
public AnbarDB()
: base("name=AnbarDB1")
{
}
public virtual DbSet<Tbl_User> Tbl_User { get; set; }
public virtual DbSet<Tbl_Customer> Tbl_Customer { get; set; }
public virtual DbSet<Tbl_Product> Tbl_Products { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
}
}
.
这个 class 是问题,当我删除这个 class 时,迁移工作
public partial class Tbl_Product
{
[Key]
public int ProductId { get; set; }
[StringLength(100)]
public string ProductName { get; set; }
public string ProductDescription { get; set; }
public long ProductLastFee { get; set; }
public int ProductLastSuply { get; set; }
public Image ProductImage { get; set; }
public DateTime DateReg { get; set; }
[ForeignKey("UserID")]
public virtual Tbl_User Users { get; set; }
public int UserID { get; set; }
}
您不能拥有 属性 ProductImage
Image
类型的 EF 实体。你将不得不存储图像,让我们说 byte[] array.