【发布时间】:2011-11-25 01:40:48
【问题描述】:
我有一个名为 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 可能指的是
dbo架构中的连接表ImporterStates。检查this answer -
我想做所有的属性而不是那个方法。但是是的,它正在对我的连接表做一些事情,但我没有在我的代码中的任何地方引用它。
-
基于属性的配置非常有限
-
知道了。我会检查另一条路径。
标签: entity-framework ef-code-first