0
如果我在OnModelCreating
覆蓋像這樣指定ToTable
:代碼第一次實體配置ToTable問題
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Team>()
.MapSingleType()
.ToTable("my_teams");
}
它創建dbo.my_teams
,但是如果我分離出來成類,像這樣:
public class TeamMap : EntityConfiguration<Team>
{
public TeamMap()
{
MapSingleType()
.ToTable("my_teams");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new TeamMap());
}
它創建dbo.Teams
。任何想法爲什麼?
這工作!但現在我似乎無法與上述組合中的運動員形成一對多的關係。使用Team.Athletes和Athlete.Team屬性。 – mxmissile 2010-08-04 20:17:25