当我运行此代码时:
IEnumerable<Processo> filtrados = db.Processoes
.Include(s => s.ProcessoClientes)
.ToList();
我有这个例外:
[SqlException(0x80131904):无效的列&#39; Cliente_ID&#39;]
ProcessoClientes类没有名为Cliente_ID的列。
public class ProcessoCliente
{
[Key]
public int ID { get; set; }
[Required]
public int PessoaID { get; set; }
public virtual Pessoa Pessoa { get; set; }
[Required]
public int CondicaoID { get; set; }
public virtual Condicao Condicao { get; set; }
[Required]
public int ProcessoID { get; set; }
public virtual Processo Processo { get; set; }
}
数据库表ProcessoClientes没有太。
然后我解决了重置我的迁移,以便在EF看到它时获取数据库中的表的映射。我收到了这个:
CreateTable(
"dbo.ProcessoClientes",
c => new
{
ID = c.Int(nullable: false, identity: true),
PessoaID = c.Int(nullable: false),
CondicaoID = c.Int(nullable: false),
ProcessoID = c.Int(nullable: false),
Cliente_ID = c.Int(),
})
.PrimaryKey(t => t.ID)
.ForeignKey("dbo.Condicaos", t => t.CondicaoID, cascadeDelete: true)
.ForeignKey("dbo.Clientes", t => t.Cliente_ID)
.ForeignKey("dbo.Pessoas", t => t.PessoaID, cascadeDelete: true)
.ForeignKey("dbo.Processoes", t => t.ProcessoID, cascadeDelete: true)
.Index(t => t.PessoaID)
.Index(t => t.CondicaoID)
.Index(t => t.ProcessoID)
.Index(t => t.Cliente_ID);
如果数据库表中不存在此列,则在安装迁移时EF会将其带到哪里?