title: How to get single entity in Entity Framework Core of model with composite key?
body: <p>I'm pretty new to C# and Entity Framework Core at all. I have a model like:</p>
  
  <pre><code>{
      public Guid CompanyCategoryId { get; set; }
  
      public Guid ParentCategoryId { get; set; }
      public virtual ParentCategory ParentCategory { get; set; }
  
      public Guid BaseCategoryId { get; set; }
      public virtual BaseCategory BaseCategory { get; set; }
  
      public Guid CompanyProfileId { get; set; }
      public virtual CompanyProfile CompanyProfile { get; set; }
  }
  </code></pre>
  
  <p>The core logic here is I want to prevent situation where one <code>CompanyProfile</code> has more than one <code>BaseCategory</code>, thus I mark these two as composite key by:</p>
  
  <pre><code>builder.Entity&lt;CompanyCategory&gt;()
      .HasKey(c =&gt; new { c.CompanyProfileId, c.BaseCategoryId });
  </code></pre>
  
  <p>Now, the question is - is there any way to have another unique value like <code>CompanyCategoryId</code> to identify single entity of this model? I need it to get/update single entity on my frontend. Currently value of this field - <code>CompanyCategoryId</code> - is Guid but filled with zeros. I guess I can combine these two composite key in DTO and send it as a string to frontend and then again split it to separate keys in the controller. But I think it's rather ugly solutions... I will be really grateful for your help</p>