/// <summary> /// Configures the table name that this entity type is mapped to. /// </summary> /// <param name="tableName"> The name of the table. </param> /// <remarks> /// Calling this will have no effect once it has been configured. /// </remarks> public ConventionTypeConfiguration <T> ToTable(string tableName) { Check.NotEmpty(tableName, "tableName"); _configuration.ToTable(tableName); return(this); }
public void ToTable_with_schema_configures() { var type = typeof(LocalEntityType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration <LocalEntityType>(type, () => innerConfig, new ModelConfiguration()); config.ToTable("foo", "bar"); Assert.Equal("foo", innerConfig.TableName); }
public void ToTable_configures_when_unset() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.ToTable("Table1"); Assert.Equal("Table1", innerConfig.TableName); }
public void ToTable_with_schema_evaluates_preconditions() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws <ArgumentException>( () => config.ToTable(null, null)); Assert.Equal(Strings.ArgumentIsNullOrWhitespace("tableName"), ex.Message); }
public void ToTable_handles_dot() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.ToTable("Schema1.Table1"); Assert.Equal("Schema1", innerConfig.SchemaName); Assert.Equal("Table1", innerConfig.TableName); }
public void ToTable_with_schema_is_noop_when_set() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); innerConfig.ToTable("Table1", "Schema1"); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.ToTable("Table2", "Schema2"); Assert.Equal("Table1", innerConfig.TableName); Assert.Equal("Schema1", innerConfig.SchemaName); }
public void ToTable_with_schema_is_noop_when_set() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); innerConfig.ToTable("Table1", "Schema1"); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.ToTable("Table2", "Schema2"); Assert.Equal("Table1", innerConfig.TableName); Assert.Equal("Schema1", innerConfig.SchemaName); }
public void ToTable_with_schema_evaluates_preconditions() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws<ArgumentException>( () => config.ToTable(null, null)); Assert.Equal(Strings.ArgumentIsNullOrWhitespace("tableName"), ex.Message); }
public void ToTable_handles_dot() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.ToTable("Schema1.Table1"); Assert.Equal("Schema1", innerConfig.SchemaName); Assert.Equal("Table1", innerConfig.TableName); }
public void ToTable_configures_when_unset() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.ToTable("Table1"); Assert.Equal("Table1", innerConfig.TableName); }
public void ToTable_with_schema_configures() { var type = typeof(LocalEntityType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration<LocalEntityType>(type, () => innerConfig, new ModelConfiguration()); config.ToTable("foo", "bar"); Assert.Equal("foo", innerConfig.TableName); }