class People
2 {
3 public int Id { get; set; }
4 public string Name { get; set; }
5 public DateTime Birth { get; set; }
6 public bool Sex { get; set; }
7 public string Description { get; set; }
8 }
9
10 class myContext : DbContext
11 {
12 public DbSet<People> peopleSet { get; set; }
13 protected override void OnModelCreating(DbModelBuilder modelBuilder)
14 {
15 modelBuilder.Configurations.Add(new PeopleConfig());
16 }
17 }
18
19 class PeopleConfig : EntityTypeConfiguration<People>
20 {
21 public PeopleConfig()
22 {
23
24 Map(m =>
25 {
26 m.Properties(p => new { p.Sex, p.Name });
27 m.ToTable("Person");
28 });
29
30 Map(m =>
31 {
32 m.Properties(p => new {p.Description, p.Birth });
33 m.ToTable("Detail");
34 });
35 }
36 }

相关文章:

  • 2021-12-23
  • 2021-07-22
  • 2022-12-23
  • 2022-01-10
  • 2021-08-30
  • 2021-06-15
  • 2021-04-20
猜你喜欢
  • 2021-11-10
  • 2022-12-23
  • 2018-04-14
  • 2018-11-24
  • 2021-09-07
  • 2021-11-22
相关资源
相似解决方案