我有一个名为ImporterState的组合表,它绑定到一个名为Importer和State的表。错误发生在这里context.Importers.Include(q => q.States)
。这是为什么发生?实体框架代码第一个和无效的对象名称错误
{ “无效的对象名称ImporterStates'。”}
[Table("HeadlineWebsiteImport", Schema = "GrassrootsHoops")]
public class Importer
{
public int Id { get; set; }
public string Name { get; set; }
public string RssUrl { get; set; }
public string Type { get; set; }
public string Keywords { get; set; }
public bool Active { get; set; }
public DateTime DateModified { get; set; }
public DateTime DateCreated { get; set; }
public int WebsiteId { get; set; }
public HeadlineWebsite Website { get; set; }
[InverseProperty("Importers")]
public ICollection<State> States { get; set; }
}
[Table("State", Schema = "GrassrootsHoops")]
public class State
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Abbr { get; set; }
[InverseProperty("States")]
public ICollection<Headline> Headlines { get; set; }
[InverseProperty("States")]
public ICollection<Importer> Importers { get; set; }
}
EF也许指的是你的连接表'ImporterStates'在'dbo'模式。检查[这个答案](http://stackoverflow.com/questions/6028375/entity-framework-code-first-many-to-many-setup-for-existing-tables/6028660#6028660) – Eranga
我想做所有属性而不是该方法。但是,是的,它正在与我的连接表做一些事情,但我没有在我的代码中的任何地方引用它。 –
基于属性的配置非常有限 – Eranga