public void Cannot_ignore_higher_source_entity_type_using_entity_type_name() { var model = new Model(); var modelBuilder = new InternalModelBuilder(model, null); Assert.True(modelBuilder.IgnoreEntity(typeof(Customer).FullName, ConfigurationSource.Convention)); Assert.NotNull(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Convention)); Assert.NotNull(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation)); Assert.False(modelBuilder.IgnoreEntity(typeof(Customer).FullName, ConfigurationSource.Convention)); Assert.NotNull(model.TryGetEntityType(typeof(Customer).FullName)); }
public void Can_ignore_lower_source_entity_type_using_entity_entity_clr_type() { var model = new Model(); var modelBuilder = new InternalModelBuilder(model, null); modelBuilder.Entity(typeof(Customer), ConfigurationSource.Convention); Assert.True(modelBuilder.IgnoreEntity(typeof(Customer), ConfigurationSource.DataAnnotation)); Assert.Null(model.TryGetEntityType(typeof(Customer))); Assert.True(modelBuilder.IgnoreEntity(typeof(Customer), ConfigurationSource.DataAnnotation)); Assert.Null(modelBuilder.Entity(typeof(Customer), ConfigurationSource.Convention)); Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.DataAnnotation)); }
public void Can_only_ignore_existing_entity_type_explicitly_using_entity_entity_clr_type() { var model = new Model(); var entityType = model.AddEntityType(typeof(Customer)); var modelBuilder = new InternalModelBuilder(model, null); Assert.Same(entityType, modelBuilder.Entity(typeof(Customer), ConfigurationSource.Convention).Metadata); Assert.False(modelBuilder.IgnoreEntity(typeof(Customer), ConfigurationSource.DataAnnotation)); Assert.Same(entityType, modelBuilder.Entity(typeof(Customer), ConfigurationSource.Convention).Metadata); Assert.False(modelBuilder.IgnoreEntity(typeof(Customer), ConfigurationSource.DataAnnotation)); Assert.NotNull(model.TryGetEntityType(typeof(Customer))); Assert.True(modelBuilder.IgnoreEntity(typeof(Customer), ConfigurationSource.Explicit)); }
public void ForeignKey_returns_null_for_property_names_if_entity_type_ignored() { var modelBuilder = new InternalModelBuilder(new Model(), null); modelBuilder.IgnoreEntity(typeof(Customer), ConfigurationSource.Explicit); var entityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); var foreignKeyBuilder = entityBuilder.ForeignKey(typeof(Customer).FullName, new[] { Order.CustomerIdProperty.Name, Order.CustomerUniqueProperty.Name }, ConfigurationSource.Convention); Assert.Null(foreignKeyBuilder); }
public void BuildRelationship_returns_null_for_clr_types_if_principal_entity_type_ignored() { var modelBuilder = new InternalModelBuilder(new Model(), null); modelBuilder.IgnoreEntity(typeof(Customer), ConfigurationSource.Explicit); var orderEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); var relationshipBuilder = orderEntityBuilder.BuildRelationship(typeof(Customer), typeof(Order), null, null, /*oneToOne:*/ true, ConfigurationSource.Convention); Assert.Null(relationshipBuilder); }
public void BuildRelationship_returns_null_for_clr_types_if_dependent_entity_type_ignored() { var modelBuilder = new InternalModelBuilder(new Model(), null); var customerEntityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit); customerEntityBuilder.Key(new[] { Customer.IdProperty, Customer.UniqueProperty }, ConfigurationSource.Explicit); modelBuilder.IgnoreEntity(typeof(Order), ConfigurationSource.Explicit); var relationshipBuilder = customerEntityBuilder.BuildRelationship(typeof(Customer), typeof(Order), null, null, /*oneToOne:*/ true, ConfigurationSource.Convention); Assert.Null(relationshipBuilder); }