【发布时间】:2015-11-09 20:15:59
【问题描述】:
我正在使用带有 RadScheduleView 的 Teleriks WPF UI,并且在将自定义约会类映射到数据库时遇到了问题。我使用的是代码优先方法,当我创建自定义资源时一切正常,但自定义约会类失败。
我在编译时得到这个内部错误。
"\r\n(6,10) : error 3004: Problem in mapping fragments starting at line 6:No mapping specified for properties Bokning.TimeZone in Set Bokning.\r\nAn Entity with Key (PK) will not round-trip when:\r\n Entity is type [TelerikWpfApp1.Bokning]\r\n"
这是我的bokning课
class Bokning : Appointment
{
public Bokning() { }
private int id;
public int Id
{
get
{
return this.Storage<Bokning>().id;
}
set
{
var storage = this.Storage<Bokning>();
if (storage.id != value)
{
storage.id = value;
this.OnPropertyChanged(() => this.Id);
}
}
}
public override IAppointment Copy()
{
var customAppointment = new Bokning();
customAppointment.CopyFrom(this);
return customAppointment;
}
public override void CopyFrom(IAppointment other)
{
var customAppointment = other as Bokning;
if (customAppointment != null)
{
this.Id = customAppointment.Id;
}
base.CopyFrom(other);
}
}
这是我的上下文
class DBContext : DbContext
{
public DBContext(): base("ADO Solutions")
{
}
public DbSet<Personal> Personal { get; set; }
public DbSet<Jobb> Jobb { get; set; }
public DbSet<Bokning> Bokning { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
Personal 和 Jobb 类可以正常工作。但是bokning课给我带来了麻烦。我认为从 Appointment 类映射 TimeZone 属性存在问题。在数据库中创建了 Bokning 表,但并非所有列都在那里。我认为它崩溃导致 TimeZone 属性是 TimeZoneInfo 对象。
我想我需要一种方法将 TimeZoneInfo 对象映射为数据库中的字符串,但我什至不确定这是不是问题所在。
编辑:我可能用了map这个词并且映射错了
【问题讨论】:
标签: c# wpf entity-framework telerik dbcontext