title: Value Object as Invalid Object in asp.net core 2.1
body: <p>I have been using value object in asp.net core 2.0 project, which was running properly on that project. </p>
  
  <p>I updated the project to 2.1 and it is giving me an error as </p>
  
  <p><code>Invalid object name 'EntityAdress'.</code> </p>
  
  <p>Entity:</p>
  
  <pre><code>public class Company : AuditableEntity&lt;long&gt;
  {
      public int SalesRepId { get; set; }
      public string Name { get; set; }
      public int StatusId { get; set; }
      public EntityAdress Addresses { get; set; }
      public string BillingAddress { get; set; }
  }
  
  public class EntityAdress : ValueObject
  {
      private EntityAdress() { }
      public string Address { get; set; }
      public string City { get; set; }
      public string State { get; set; }
      public int Zip { get; set; }
  
      protected override IEnumerable&lt;object&gt; GetAtomicValues()
      {
          yield return Address;
          yield return City;
          yield return State;
          yield return Zip;
      }
  }
  </code></pre>
  
  <p>The implementation for ValueObject is exact same from the <a href="https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/implement-value-objects" rel="nofollow noreferrer">Link for the eshopContainer examples of value objects</a></p>
  
  <p>The Package i am using for the projects which contains the <code>DbContext</code></p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
  
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.1&lt;/TargetFramework&gt;
      &lt;RuntimeFrameworkVersion&gt;2.1.6&lt;/RuntimeFrameworkVersion&gt;
    &lt;/PropertyGroup&gt;
  
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="IdentityServer4.AspNetIdentity" Version="1.0.1" /&gt;
      &lt;PackageReference Include="IdentityServer4.EntityFramework" Version="2.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.0" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.0" /&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>Context:</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      modelBuilder.RemovePluralizingTableNameConvention();
      modelBuilder.OnDeleteCascading();
  
      modelBuilder.ApplyConfiguration(new CompanyEntityTypeConfiguraton());
  
      base.OnModelCreating(modelBuilder);
  
  }
  </code></pre>
  
  <p>CompanyEntityTypeConfiguraton:</p>
  
  <pre><code>public class CompanyEntityTypeConfiguraton : IEntityTypeConfiguration&lt;Company&gt;
  {
      public void Configure(EntityTypeBuilder&lt;Company&gt; orderConfiguration)
      {
          orderConfiguration.OwnsOne(p =&gt; p.Addresses, cb =&gt;
          {
              cb.Property(p =&gt; p.City).HasColumnName("City");
              cb.Property(p =&gt; p.Address).HasColumnName("Address");
              cb.Property(p =&gt; p.State).HasColumnName("State");
              cb.Property(p =&gt; p.Zip).HasColumnName("Zip");
          });
  
      }
  }
  </code></pre>
  
  <p>OnDeleteCascading and RemovePluralizingTableNameConvention:</p>
  
  <pre><code>public static class ModelBuilderExtensions
  {
      public static void RemovePluralizingTableNameConvention(this ModelBuilder modelBuilder)
      {
          foreach (IMutableEntityType entity in modelBuilder.Model.GetEntityTypes())
          {
              entity.Relational().TableName = entity.DisplayName();
          }
      }
      public static void OnDeleteCascading(this ModelBuilder modelBuilder)
      {
          foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e =&gt; e.GetForeignKeys()))
          {
              relationship.DeleteBehavior = DeleteBehavior.Restrict;
          }
      }
  
  }
  </code></pre>
  
  <p>What could be the reason for the problems? Is it the problem with the Entity Framework version or something missing on the implementations?</p>