Using a junction table in a many to many relationship












1















I am learning EF Core. Say I have a many to many relationship with a junction table like this:



public class PostTag
{
public int PostId { get; set; }
public Post Post { get; set; }

public int TagId { get; set; }
public Tag Tag { get; set; }
}


Say I wanted to perform a database insert.



var post = new Post { Id=Guid.NewGuid(), Description="Test Post" };
var tag = new Tag { Id=Guid.NewGuid(), Description="Test Text" };
var PostTag = new PostTag { Post=post; Tag=tag; PostId=Post.Id, TagId=Tag.Id};
context.Add(PostTag);


This one insert appears to:



1) Insert a post.
2) Insert a Tag
3) Insert a PostTag


Q1) Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.



Q2) Does adding a PostTag also add the Post and the Tag?










share|improve this question



























    1















    I am learning EF Core. Say I have a many to many relationship with a junction table like this:



    public class PostTag
    {
    public int PostId { get; set; }
    public Post Post { get; set; }

    public int TagId { get; set; }
    public Tag Tag { get; set; }
    }


    Say I wanted to perform a database insert.



    var post = new Post { Id=Guid.NewGuid(), Description="Test Post" };
    var tag = new Tag { Id=Guid.NewGuid(), Description="Test Text" };
    var PostTag = new PostTag { Post=post; Tag=tag; PostId=Post.Id, TagId=Tag.Id};
    context.Add(PostTag);


    This one insert appears to:



    1) Insert a post.
    2) Insert a Tag
    3) Insert a PostTag


    Q1) Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.



    Q2) Does adding a PostTag also add the Post and the Tag?










    share|improve this question

























      1












      1








      1








      I am learning EF Core. Say I have a many to many relationship with a junction table like this:



      public class PostTag
      {
      public int PostId { get; set; }
      public Post Post { get; set; }

      public int TagId { get; set; }
      public Tag Tag { get; set; }
      }


      Say I wanted to perform a database insert.



      var post = new Post { Id=Guid.NewGuid(), Description="Test Post" };
      var tag = new Tag { Id=Guid.NewGuid(), Description="Test Text" };
      var PostTag = new PostTag { Post=post; Tag=tag; PostId=Post.Id, TagId=Tag.Id};
      context.Add(PostTag);


      This one insert appears to:



      1) Insert a post.
      2) Insert a Tag
      3) Insert a PostTag


      Q1) Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.



      Q2) Does adding a PostTag also add the Post and the Tag?










      share|improve this question














      I am learning EF Core. Say I have a many to many relationship with a junction table like this:



      public class PostTag
      {
      public int PostId { get; set; }
      public Post Post { get; set; }

      public int TagId { get; set; }
      public Tag Tag { get; set; }
      }


      Say I wanted to perform a database insert.



      var post = new Post { Id=Guid.NewGuid(), Description="Test Post" };
      var tag = new Tag { Id=Guid.NewGuid(), Description="Test Text" };
      var PostTag = new PostTag { Post=post; Tag=tag; PostId=Post.Id, TagId=Tag.Id};
      context.Add(PostTag);


      This one insert appears to:



      1) Insert a post.
      2) Insert a Tag
      3) Insert a PostTag


      Q1) Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.



      Q2) Does adding a PostTag also add the Post and the Tag?







      asp.net-core entity-framework-core






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 27 '18 at 20:47









      w0051977w0051977

      5,8791378177




      5,8791378177
























          1 Answer
          1






          active

          oldest

          votes


















          0















          Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.




          As you know, the PostTag.PostId is a foreign key that references the Post.Id, and the PostTag.TagId is a foreign key which references the Tag.Id. The PostTag.PostId called Foreign Key Property and PostTag.Post is Navigation Property.



          Actually, if you don't have a foreign key property for navigation property explicitly, the EF Core will also work as expected. In that case, two shadow foreign key properties of PostId and TagId will be introduced for you automatically. It is called Shadow Properties.




          Shadow properties can be created by convention when a relationship is discovered but no foreign key property is found in the dependent entity class. In this case, a shadow foreign key property will be introduced. The shadow foreign key property will be named <navigation property name><principal key property name> (the navigation on the dependent entity, which points to the principal entity, is used for the naming). If the principal key property name includes the name of the navigation property, then the name will just be <principal key property name>. If there is no navigation property on the dependent entity, then the principal type name is used in its place.






          1. Although these foreign key can be inferred by the PostTag.Post.Id and PostTag.Tag.Id respectively, they're not duplicated.



            Let's say we have an existing database where the foreign keys are named as fk_post_id and fk_tag_id, and you want to rename the foreign key property PostId to MyPostId, we cannot omit the PostId and TagId properties :



            public class PostTag
            {
            [Column("fk_post_id")]
            public Guid MyPostId { get; set; }
            [ForeignKey("MyPostId")]
            public Post Post { get; set; }


            [Column("fk_tag_id")]
            public Guid TagId { get; set; }
            public Tag Tag { get; set; }
            }


          2. It is recommended to have a foreign key property defined in the dependent entity class for the navigation property




          Does adding a PostTag also add the Post and the Tag?




          Your code inserts a post and tag automatically for you because it knows that you need to create a brand new post and a brand new tag. But that's not always that case. It depends on the tracking state and the entity itself.



          If you execute the following code :



              var tagTracked = this._dbContext.Tag.FirstOrDefault();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          The tagTracked will not be inserted . If you want to insert a new tag record , you need to make the tag untracked :



              var tagTracked = this._dbContext.Tag.AsNoTracking().FirstOrDefault();
          tagTracked.Id = Guid.NewGuid();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          Again, it will insert a new tag record in the database. For more information, refer docs here






          share|improve this answer


























          • Thanks. If you have a many to many relationship then I believe you have to have a junction entity (Post-war in this case). This seems to be a significant downside of ef core. Is that right? I have seen the github article - I just want to make sure it is still true after many years.

            – w0051977
            Nov 28 '18 at 7:50











          • @w0051977 You're right. According to the official document , for the time being, EF Core will not automatically take care of Many-to-Many relationship without a junction entity for us .

            – itminus
            Nov 28 '18 at 8:25











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507898%2fusing-a-junction-table-in-a-many-to-many-relationship%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0















          Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.




          As you know, the PostTag.PostId is a foreign key that references the Post.Id, and the PostTag.TagId is a foreign key which references the Tag.Id. The PostTag.PostId called Foreign Key Property and PostTag.Post is Navigation Property.



          Actually, if you don't have a foreign key property for navigation property explicitly, the EF Core will also work as expected. In that case, two shadow foreign key properties of PostId and TagId will be introduced for you automatically. It is called Shadow Properties.




          Shadow properties can be created by convention when a relationship is discovered but no foreign key property is found in the dependent entity class. In this case, a shadow foreign key property will be introduced. The shadow foreign key property will be named <navigation property name><principal key property name> (the navigation on the dependent entity, which points to the principal entity, is used for the naming). If the principal key property name includes the name of the navigation property, then the name will just be <principal key property name>. If there is no navigation property on the dependent entity, then the principal type name is used in its place.






          1. Although these foreign key can be inferred by the PostTag.Post.Id and PostTag.Tag.Id respectively, they're not duplicated.



            Let's say we have an existing database where the foreign keys are named as fk_post_id and fk_tag_id, and you want to rename the foreign key property PostId to MyPostId, we cannot omit the PostId and TagId properties :



            public class PostTag
            {
            [Column("fk_post_id")]
            public Guid MyPostId { get; set; }
            [ForeignKey("MyPostId")]
            public Post Post { get; set; }


            [Column("fk_tag_id")]
            public Guid TagId { get; set; }
            public Tag Tag { get; set; }
            }


          2. It is recommended to have a foreign key property defined in the dependent entity class for the navigation property




          Does adding a PostTag also add the Post and the Tag?




          Your code inserts a post and tag automatically for you because it knows that you need to create a brand new post and a brand new tag. But that's not always that case. It depends on the tracking state and the entity itself.



          If you execute the following code :



              var tagTracked = this._dbContext.Tag.FirstOrDefault();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          The tagTracked will not be inserted . If you want to insert a new tag record , you need to make the tag untracked :



              var tagTracked = this._dbContext.Tag.AsNoTracking().FirstOrDefault();
          tagTracked.Id = Guid.NewGuid();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          Again, it will insert a new tag record in the database. For more information, refer docs here






          share|improve this answer


























          • Thanks. If you have a many to many relationship then I believe you have to have a junction entity (Post-war in this case). This seems to be a significant downside of ef core. Is that right? I have seen the github article - I just want to make sure it is still true after many years.

            – w0051977
            Nov 28 '18 at 7:50











          • @w0051977 You're right. According to the official document , for the time being, EF Core will not automatically take care of Many-to-Many relationship without a junction entity for us .

            – itminus
            Nov 28 '18 at 8:25
















          0















          Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.




          As you know, the PostTag.PostId is a foreign key that references the Post.Id, and the PostTag.TagId is a foreign key which references the Tag.Id. The PostTag.PostId called Foreign Key Property and PostTag.Post is Navigation Property.



          Actually, if you don't have a foreign key property for navigation property explicitly, the EF Core will also work as expected. In that case, two shadow foreign key properties of PostId and TagId will be introduced for you automatically. It is called Shadow Properties.




          Shadow properties can be created by convention when a relationship is discovered but no foreign key property is found in the dependent entity class. In this case, a shadow foreign key property will be introduced. The shadow foreign key property will be named <navigation property name><principal key property name> (the navigation on the dependent entity, which points to the principal entity, is used for the naming). If the principal key property name includes the name of the navigation property, then the name will just be <principal key property name>. If there is no navigation property on the dependent entity, then the principal type name is used in its place.






          1. Although these foreign key can be inferred by the PostTag.Post.Id and PostTag.Tag.Id respectively, they're not duplicated.



            Let's say we have an existing database where the foreign keys are named as fk_post_id and fk_tag_id, and you want to rename the foreign key property PostId to MyPostId, we cannot omit the PostId and TagId properties :



            public class PostTag
            {
            [Column("fk_post_id")]
            public Guid MyPostId { get; set; }
            [ForeignKey("MyPostId")]
            public Post Post { get; set; }


            [Column("fk_tag_id")]
            public Guid TagId { get; set; }
            public Tag Tag { get; set; }
            }


          2. It is recommended to have a foreign key property defined in the dependent entity class for the navigation property




          Does adding a PostTag also add the Post and the Tag?




          Your code inserts a post and tag automatically for you because it knows that you need to create a brand new post and a brand new tag. But that's not always that case. It depends on the tracking state and the entity itself.



          If you execute the following code :



              var tagTracked = this._dbContext.Tag.FirstOrDefault();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          The tagTracked will not be inserted . If you want to insert a new tag record , you need to make the tag untracked :



              var tagTracked = this._dbContext.Tag.AsNoTracking().FirstOrDefault();
          tagTracked.Id = Guid.NewGuid();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          Again, it will insert a new tag record in the database. For more information, refer docs here






          share|improve this answer


























          • Thanks. If you have a many to many relationship then I believe you have to have a junction entity (Post-war in this case). This seems to be a significant downside of ef core. Is that right? I have seen the github article - I just want to make sure it is still true after many years.

            – w0051977
            Nov 28 '18 at 7:50











          • @w0051977 You're right. According to the official document , for the time being, EF Core will not automatically take care of Many-to-Many relationship without a junction entity for us .

            – itminus
            Nov 28 '18 at 8:25














          0












          0








          0








          Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.




          As you know, the PostTag.PostId is a foreign key that references the Post.Id, and the PostTag.TagId is a foreign key which references the Tag.Id. The PostTag.PostId called Foreign Key Property and PostTag.Post is Navigation Property.



          Actually, if you don't have a foreign key property for navigation property explicitly, the EF Core will also work as expected. In that case, two shadow foreign key properties of PostId and TagId will be introduced for you automatically. It is called Shadow Properties.




          Shadow properties can be created by convention when a relationship is discovered but no foreign key property is found in the dependent entity class. In this case, a shadow foreign key property will be introduced. The shadow foreign key property will be named <navigation property name><principal key property name> (the navigation on the dependent entity, which points to the principal entity, is used for the naming). If the principal key property name includes the name of the navigation property, then the name will just be <principal key property name>. If there is no navigation property on the dependent entity, then the principal type name is used in its place.






          1. Although these foreign key can be inferred by the PostTag.Post.Id and PostTag.Tag.Id respectively, they're not duplicated.



            Let's say we have an existing database where the foreign keys are named as fk_post_id and fk_tag_id, and you want to rename the foreign key property PostId to MyPostId, we cannot omit the PostId and TagId properties :



            public class PostTag
            {
            [Column("fk_post_id")]
            public Guid MyPostId { get; set; }
            [ForeignKey("MyPostId")]
            public Post Post { get; set; }


            [Column("fk_tag_id")]
            public Guid TagId { get; set; }
            public Tag Tag { get; set; }
            }


          2. It is recommended to have a foreign key property defined in the dependent entity class for the navigation property




          Does adding a PostTag also add the Post and the Tag?




          Your code inserts a post and tag automatically for you because it knows that you need to create a brand new post and a brand new tag. But that's not always that case. It depends on the tracking state and the entity itself.



          If you execute the following code :



              var tagTracked = this._dbContext.Tag.FirstOrDefault();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          The tagTracked will not be inserted . If you want to insert a new tag record , you need to make the tag untracked :



              var tagTracked = this._dbContext.Tag.AsNoTracking().FirstOrDefault();
          tagTracked.Id = Guid.NewGuid();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          Again, it will insert a new tag record in the database. For more information, refer docs here






          share|improve this answer
















          Why does PostTag contain PostId and TagId? This information is contained in Post and Tag (also two fields in PostTag). It appears that these fields are duplicated.




          As you know, the PostTag.PostId is a foreign key that references the Post.Id, and the PostTag.TagId is a foreign key which references the Tag.Id. The PostTag.PostId called Foreign Key Property and PostTag.Post is Navigation Property.



          Actually, if you don't have a foreign key property for navigation property explicitly, the EF Core will also work as expected. In that case, two shadow foreign key properties of PostId and TagId will be introduced for you automatically. It is called Shadow Properties.




          Shadow properties can be created by convention when a relationship is discovered but no foreign key property is found in the dependent entity class. In this case, a shadow foreign key property will be introduced. The shadow foreign key property will be named <navigation property name><principal key property name> (the navigation on the dependent entity, which points to the principal entity, is used for the naming). If the principal key property name includes the name of the navigation property, then the name will just be <principal key property name>. If there is no navigation property on the dependent entity, then the principal type name is used in its place.






          1. Although these foreign key can be inferred by the PostTag.Post.Id and PostTag.Tag.Id respectively, they're not duplicated.



            Let's say we have an existing database where the foreign keys are named as fk_post_id and fk_tag_id, and you want to rename the foreign key property PostId to MyPostId, we cannot omit the PostId and TagId properties :



            public class PostTag
            {
            [Column("fk_post_id")]
            public Guid MyPostId { get; set; }
            [ForeignKey("MyPostId")]
            public Post Post { get; set; }


            [Column("fk_tag_id")]
            public Guid TagId { get; set; }
            public Tag Tag { get; set; }
            }


          2. It is recommended to have a foreign key property defined in the dependent entity class for the navigation property




          Does adding a PostTag also add the Post and the Tag?




          Your code inserts a post and tag automatically for you because it knows that you need to create a brand new post and a brand new tag. But that's not always that case. It depends on the tracking state and the entity itself.



          If you execute the following code :



              var tagTracked = this._dbContext.Tag.FirstOrDefault();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          The tagTracked will not be inserted . If you want to insert a new tag record , you need to make the tag untracked :



              var tagTracked = this._dbContext.Tag.AsNoTracking().FirstOrDefault();
          tagTracked.Id = Guid.NewGuid();
          var post = new Post { Id=Guid.NewGuid(), Description="Test Post3" };
          var PostTag = new PostTag {
          Post=post,
          Tag=tagTracked,
          MyPostId= post.Id,
          TagId= tagTracked.Id,
          };
          this._dbContext.Add(PostTag);
          this._dbContext.SaveChanges();


          Again, it will insert a new tag record in the database. For more information, refer docs here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 28 '18 at 7:03

























          answered Nov 28 '18 at 6:39









          itminusitminus

          4,0731423




          4,0731423













          • Thanks. If you have a many to many relationship then I believe you have to have a junction entity (Post-war in this case). This seems to be a significant downside of ef core. Is that right? I have seen the github article - I just want to make sure it is still true after many years.

            – w0051977
            Nov 28 '18 at 7:50











          • @w0051977 You're right. According to the official document , for the time being, EF Core will not automatically take care of Many-to-Many relationship without a junction entity for us .

            – itminus
            Nov 28 '18 at 8:25



















          • Thanks. If you have a many to many relationship then I believe you have to have a junction entity (Post-war in this case). This seems to be a significant downside of ef core. Is that right? I have seen the github article - I just want to make sure it is still true after many years.

            – w0051977
            Nov 28 '18 at 7:50











          • @w0051977 You're right. According to the official document , for the time being, EF Core will not automatically take care of Many-to-Many relationship without a junction entity for us .

            – itminus
            Nov 28 '18 at 8:25

















          Thanks. If you have a many to many relationship then I believe you have to have a junction entity (Post-war in this case). This seems to be a significant downside of ef core. Is that right? I have seen the github article - I just want to make sure it is still true after many years.

          – w0051977
          Nov 28 '18 at 7:50





          Thanks. If you have a many to many relationship then I believe you have to have a junction entity (Post-war in this case). This seems to be a significant downside of ef core. Is that right? I have seen the github article - I just want to make sure it is still true after many years.

          – w0051977
          Nov 28 '18 at 7:50













          @w0051977 You're right. According to the official document , for the time being, EF Core will not automatically take care of Many-to-Many relationship without a junction entity for us .

          – itminus
          Nov 28 '18 at 8:25





          @w0051977 You're right. According to the official document , for the time being, EF Core will not automatically take care of Many-to-Many relationship without a junction entity for us .

          – itminus
          Nov 28 '18 at 8:25




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507898%2fusing-a-junction-table-in-a-many-to-many-relationship%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks