1- using Microsoft . EntityFrameworkCore ;
2- using EfCore . Ydb . Extensions ;
1+ using EfCore . Ydb . Extensions ;
2+ using Microsoft . EntityFrameworkCore ;
33
44await using var db = new BloggingContext ( ) ;
55
@@ -34,18 +34,24 @@ protected override void OnConfiguring(DbContextOptionsBuilder options)
3434
3535internal class Blog
3636{
37- public int BlogId { get ; set ; }
38- public string Url { get ; set ; }
37+ public int BlogId { get ; init ; }
3938
40- public List < Post > Posts { get ; } = new ( ) ;
39+ // ReSharper disable once EntityFramework.ModelValidation.UnlimitedStringLength
40+ public string Url { get ; set ; } = string . Empty ;
41+
42+ // ReSharper disable once CollectionNeverQueried.Global
43+ public List < Post > Posts { get ; init ; } = [ ] ;
4144}
4245
4346internal class Post
4447{
45- public int PostId { get ; set ; }
46- public string Title { get ; set ; }
47- public string Content { get ; set ; }
48+ public int PostId { get ; init ; }
49+
50+ // ReSharper disable once EntityFramework.ModelValidation.UnlimitedStringLength
51+ public string Title { get ; init ; } = string . Empty ;
52+
53+ // ReSharper disable once EntityFramework.ModelValidation.UnlimitedStringLength
54+ public string Content { get ; init ; } = string . Empty ;
4855
49- public int BlogId { get ; set ; }
50- public Blog Blog { get ; set ; }
56+ public Blog Blog { get ; init ; } = null ! ;
5157}
0 commit comments