【发布时间】:2012-02-08 08:19:32
【问题描述】:
我正在开发一个包含 3 个表的数据库
出行模式:
[Key]
public int TripId { get; set; }
[ForeignKey("Driver")]
public int DriverId { get; set; }
public virtual Driver Driver { get; set; }
public string StartingPoint { get; set; }
public string Destination { get; set; }
public DateTime TimeDepart { get; set; }
public int SeatAvailable { get; set; }
public virtual ICollection<Driver> Drivers { get; set; }
public virtual ICollection<Passenger> Passengers { get; set; }
驱动器型号:
[Key]
public int DriverId { get; set; }
public string DriverName { get; set; }
[ForeignKey("Trip"), Column(Order = 0)]
public int TripId { get; set; }
public virtual Trip Trip { get; set; }
最后一位乘客模型:
[Key]
public int PassengerId { get; set; }
public string PassengerName { get; set; }
[ForeignKey("Trip"), Column(Order = 1)]
public int TripId { get; set; }
public virtual Trip Trip { get; set; }
与:
public class LiveGreenContext: DbContext
{
public DbSet<Trip> Trips { get; set; }
public DbSet<Driver> Drivers { get; set; }
public DbSet<Passenger> Passengers { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
}
我收到以下错误:
无法检查模型兼容性,因为 EdmMetadata 类型是 不包括在模型中。确保 IncludeMetadataConvention 具有 已添加到 DbModelBuilder 约定中。
关于这个问题的任何解决方案?谢谢!
【问题讨论】:
-
你有初始化设置吗?
标签: c# linq asp.net-mvc-3 entity-framework-4 entity-framework-4.1