public void Entity_returns_same_instance_for_entity_type_name() { var model = new Model(); var modelBuilder = new InternalModelBuilder(model, null); var entityBuilder = modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation); Assert.NotNull(entityBuilder); Assert.NotNull(model.TryGetEntityType(typeof(Customer).FullName)); Assert.Same(entityBuilder, modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit)); }
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 Cannot_ignore_same_or_higher_source_entity_type_using_entity_clr_type() { var model = new Model(); var modelBuilder = new InternalModelBuilder(model, null); Assert.True(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation)); Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.DataAnnotation)); Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit)); Assert.False(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation)); Assert.NotNull(model.TryGetEntityType(typeof(Customer))); }
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 Can_ignore_lower_source_entity_type_using_entity_type_name() { var model = new Model(); var modelBuilder = new InternalModelBuilder(model, null); modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation); Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit)); Assert.Null(model.TryGetEntityType(typeof(Customer).FullName)); Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit)); Assert.Null(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation)); Assert.Equal(Strings.EntityIgnoredExplicitly(typeof(Customer).FullName), Assert.Throws <InvalidOperationException>(() => Assert.Null(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Explicit))).Message); }
public void Cannot_ignore_existing_entity_type_using_entity_type_name() { var model = new Model(); var entityType = model.AddEntityType(typeof(Customer).FullName); var modelBuilder = new InternalModelBuilder(model, null); Assert.Same(entityType, modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Convention).Metadata); Assert.False(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.DataAnnotation)); Assert.Same(entityType, modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Convention).Metadata); Assert.False(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.DataAnnotation)); Assert.NotNull(model.TryGetEntityType(typeof(Customer).FullName)); Assert.Equal(Strings.EntityAddedExplicitly(typeof(Customer).FullName), Assert.Throws <InvalidOperationException>(() => Assert.False(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit))).Message); }