title: Configure a many to one relationship in a Owned Entity in Entity Framework
body: <p>I have a class that is an entity in the DB and has a owned entity:</p>
  <pre><code>public class EntityOne
  {
          public int Id { get; set; }
          public OwnedEntity OwnedEntity { get; set; }
  }
  </code></pre>
  <p>I have the owned entity with a list with the type of another persisted entity:</p>
  <pre><code>public class OwnedEntity
  {
          public int Id { get; set; }
          public List&lt;EntityTwo&gt; EntityTwo { get; set; }
  }
  </code></pre>
  <p>And here is the EntityTwo:</p>
  <pre><code>public class EntityTwo
  {
          public int Id { get; set; }
   
          // all other properties
  }
  </code></pre>
  <p><strong>I need to create the relationship between EntityOne and EntityTwo as a many to one, but the property navigation is in my owned entity. How can I do that?</strong></p>
  <p>I tried to create a property navigation of my owned entity like this:</p>
  <pre><code>public class EntityTwo
  {
          public int Id { get; set; }
  
          public OwnedEntity OwnedEntity { get; set; }
  
          public int OwnedEntityId { get; set; }
  
          // all other properties
  }
  </code></pre>
  <p>And the map:</p>
  <pre><code>builder.HasOne(prop =&gt; prop.OwnedEntity)
                  .WithMany(prop =&gt; prop.EntityTwo)
                  .HasForeignKey(prop =&gt; prop.OwnedEntityId);
  </code></pre>
  <p>But I got an error because ef tries to make my owned entity as a entity table.</p>
  <p>Then, I tried to reference the parent entity:</p>
  <pre><code>public class EntityTwo
  {
              public int Id { get; set; }
      
              public EntityOne EntityOne { get; set; }
      
              public int EntityOneId { get; set; }
      
              // all other properties
  }
  </code></pre>
  <p>And mapping with inner properties:</p>
  <pre><code>builder.HasOne(prop =&gt; prop.EntityOne.OwnedEntity)
                  .WithMany(prop =&gt; prop.EntityTwo)
                  .HasForeignKey(prop =&gt; prop.EntityOne.OwnedEntityId);
  </code></pre>
  <p>But it didn't work and i got another ef error:</p>
  <pre><code>Error: The expression 'prop =&gt; prop.EntityOne.OwnedEntity' is not a valid member access expression. The expression should represent a simple property or field access: 't =&gt; t.MyProperty'. (Parameter 'memberAccessExpression')
  </code></pre>
  <p><strong>So, is there any way to create this relationship?</strong></p>