public void Can_mark_type_as_owned_type() { var model = new Model(); var modelBuilder = CreateModelBuilder(model); var entityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit); Assert.NotNull(modelBuilder.Entity(typeof(Details), ConfigurationSource.Convention)); Assert.False(model.ShouldBeOwned(typeof(Details))); Assert.NotNull(entityBuilder.HasOwnership(typeof(Details), nameof(Customer.Details), ConfigurationSource.Convention)); Assert.NotNull(modelBuilder.Ignore(typeof(Details), ConfigurationSource.Convention)); Assert.Empty(model.GetEntityTypes(typeof(Details))); Assert.Null(entityBuilder.HasOwnership(typeof(Details), nameof(Customer.Details), ConfigurationSource.Convention)); Assert.Null(modelBuilder.Owned(typeof(Details), ConfigurationSource.Convention)); Assert.NotNull(entityBuilder.HasOwnership(typeof(Details), nameof(Customer.Details), ConfigurationSource.DataAnnotation)); Assert.NotNull(modelBuilder.Owned(typeof(Details), ConfigurationSource.Convention)); Assert.NotNull(modelBuilder.Owned(typeof(Details), ConfigurationSource.DataAnnotation)); Assert.True(model.ShouldBeOwned(typeof(Details))); Assert.NotNull( modelBuilder.Entity(typeof(Product), ConfigurationSource.Explicit) .HasOwnership(typeof(Details), nameof(Product.Details), ConfigurationSource.Convention)); Assert.Null(modelBuilder.Ignore(typeof(Details), ConfigurationSource.Convention)); Assert.Equal(2, model.GetEntityTypes(typeof(Details)).Count); Assert.Equal( CoreStrings.ClashingOwnedEntityType(typeof(Details).Name), Assert.Throws <InvalidOperationException>(() => modelBuilder.Entity(typeof(Details), ConfigurationSource.Explicit)).Message); Assert.NotNull(modelBuilder.Ignore(typeof(Details), ConfigurationSource.Explicit)); Assert.False(model.ShouldBeOwned(typeof(Details))); Assert.NotNull(modelBuilder.Entity(typeof(Details), ConfigurationSource.Explicit)); Assert.Empty(model.GetEntityTypes(typeof(Details)).Where(e => e.DefiningNavigationName != null)); Assert.Null(modelBuilder.Owned(typeof(Details), ConfigurationSource.Convention)); Assert.Equal( CoreStrings.ClashingNonOwnedEntityType(typeof(Details).Name), Assert.Throws <InvalidOperationException>(() => modelBuilder.Owned(typeof(Details), ConfigurationSource.Explicit)).Message); }