Skip to content

Commit 6434be8

Browse files
2881028810
authored andcommitted
update EFCoreFluentApi readme
1 parent 03fe092 commit 6434be8

File tree

1 file changed

+29
-0
lines changed
  • Extensions/FreeSql.Extensions.EfCoreFluentApi

1 file changed

+29
-0
lines changed

Extensions/FreeSql.Extensions.EfCoreFluentApi/readme.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,34 @@ static void Test()
2929
//多对多
3030
eb.HasMany(a => a.Tags).WithMany(a => a.Songs, typeof(Song_tag));
3131
});
32+
33+
cf.Entity<SongType>(eb =>
34+
{
35+
eb.HasMany(a => a.Songs).WithOne(a => a.Type).HasForeignKey(a => a.TypeId);
36+
37+
eb.HasData(new[]
38+
{
39+
new SongType
40+
{
41+
Id = 1,
42+
Name = "流行",
43+
Songs = new List<Song>(new[]
44+
{
45+
new Song{ Title = "真的爱你" },
46+
new Song{ Title = "爱你一万年" },
47+
})
48+
},
49+
new SongType
50+
{
51+
Id = 2,
52+
Name = "乡村",
53+
Songs = new List<Song>(new[]
54+
{
55+
new Song{ Title = "乡里乡亲" },
56+
})
57+
},
58+
});
59+
});
3260
}
3361

3462
public class SongType
@@ -41,6 +69,7 @@ public class SongType
4169

4270
public class Song
4371
{
72+
[Column(IsIdentity = true)]
4473
public int Id { get; set; }
4574
public string Title { get; set; }
4675
public string Url { get; set; }

0 commit comments

Comments
 (0)