Skip to content

Commit

Permalink
[6.0] RevEng: Initialize skip collection navigations in ctor (#26212)
Browse files Browse the repository at this point in the history
* RevEng: Initialize skip collection navigations in ctor

Resolves #26206
  • Loading branch information
smitpatel authored Sep 30, 2021
1 parent d5a02d7 commit 3b300c1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ protected virtual void GenerateConstructor(IEntityType entityType)
{
Check.NotNull(entityType, nameof(entityType));

var collectionNavigations = entityType.GetNavigations().Where(n => n.IsCollection).ToList();
var collectionNavigations = entityType.GetDeclaredNavigations()
.Cast<INavigationBase>()
.Concat(entityType.GetDeclaredSkipNavigations())
.Where(n => n.IsCollection)
.ToList();

if (collectionNavigations.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,11 @@ namespace TestNamespace
{
public partial class Blog
{
public Blog()
{
Posts = new HashSet<Post>();
}
public int Id { get; set; }
public virtual ICollection<Post> Posts { get; set; }
Expand All @@ -2138,6 +2143,11 @@ namespace TestNamespace
{
public partial class Post
{
public Post()
{
Blogs = new HashSet<Blog>();
}
public int Id { get; set; }
public virtual ICollection<Blog> Blogs { get; set; }
Expand Down Expand Up @@ -2258,6 +2268,11 @@ namespace TestNamespace
{
public partial class Blog
{
public Blog()
{
Posts = new HashSet<Post>();
}
public int Id { get; set; }
public virtual ICollection<Post> Posts { get; set; }
Expand All @@ -2273,6 +2288,11 @@ namespace TestNamespace
{
public partial class Post
{
public Post()
{
Blogs = new HashSet<Blog>();
}
public string Id { get; set; }
public virtual ICollection<Blog> Blogs { get; set; }
Expand Down Expand Up @@ -2401,6 +2421,11 @@ namespace TestNamespace
{
public partial class Blog
{
public Blog()
{
Posts = new HashSet<Post>();
}
[Key]
public int Id { get; set; }
Expand All @@ -2422,6 +2447,11 @@ namespace TestNamespace
{
public partial class Post
{
public Post()
{
Blogs = new HashSet<Blog>();
}
[Key]
public int Id { get; set; }
Expand Down

0 comments on commit 3b300c1

Please sign in to comment.