我正在使用Fluent API实现实体框架和代码优先技术。
我已经有一个表的映射:
modelBuilder.Entity<Certificate>()
.HasMany( c => c.Employees ).WithMany( e => e.Certificates )
.Map( m => {
m.ToTable( "Employee_Certificate" );
m.MapLeftKey( "CertificateId" );
m.MapRightKey( "EmployeeId" );
} );
我想知道的是,我是否还需要为员工实体进行等效映射?
类似的东西:
modelBuilder.Entity<Employee>()
.HasMany( e => e.Certificates ).WithMany( c => c.Employees )
.Map( m => {
m.ToTable( "Employee_Certificate" );
m.MapLeftKey( "EmployeeId" );
m.MapRightKey( "CertificateId" );
} );
或简单的HasMany(...).WithMany(...)
是否足够好?