如何使用Entity Framework Core显示3个表中的数据

问题描述

我的数据库中有3个表,它们是它们的EF模型:

 h.Values
  .Cast<Array>()
  .SelectMany(a => a.Cast<IComparable>())
  .Select(c => Convert.ToDouble(c))

数据库上下文:

public class Customer
{
    [Key]
    public string Name { get; set; }
    public string ContactID { get; set; }
    public string VehicleID { get; set; }
    public IList<Contact> Contacts { get; set; }      
    public IList<Vehicle> Vehicles { get; set; }
}
public class Vehicle
{
   [Key]
   public string VehicleID {get; set;}
   public string Make {get; set;}
}

public class Contact
{
   [Key]
   public string ContactID {get; set;}
   public string Name {get; set;}
}

在我的控制器中:

protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.Entity<Customer>().HasKey(q => new { q.ContactID,q.VehicleID });
         }
        //Defining entities for context class
        public DbSet<Contact> Contacts { get; set; }
        public DbSet<Vehicle> Vehicles { get; set; }
        public DbSet<Customer> Customers { get; set; }

我的目标是从三个表中返回数据,但是当我运行它时,出现错误:SqlException:无效的列名CustomerContactID CustomerVehicleID

任何帮助表示赞赏

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...