/// <summary> /// Sets an annotation in the model for the table to which this entity is mapped. The annotation /// value can later be used when processing the table such as when creating migrations. /// </summary> /// <remarks> /// It will likely be necessary to register a <see cref="IMetadataAnnotationSerializer"/> if the type of /// the annotation value is anything other than a string. Passing a null value clears any annotation with /// the given name on the column that had been previously set. /// </remarks> /// <param name="name">The annotation name, which must be a valid C#/EDM identifier.</param> /// <param name="value">The annotation value, which may be a string or some other type that /// can be serialized with an <see cref="IMetadataAnnotationSerializer"/></param>. /// <returns>The same configuration instance so that multiple calls can be chained.</returns> public EntityTypeConfiguration <TEntityType> HasTableAnnotation(string name, object value) { Check.NotEmpty(name, "name"); _entityTypeConfiguration.SetAnnotation(name, value); return(this); }
public void Cloning_an_entity_configuration_clones_its_mapping_information() { var configuration = new EntityTypeConfiguration(typeof(object)); configuration.ToTable("Table"); configuration.SetAnnotation("A1", "V1"); var clone = configuration.Clone(); Assert.Equal("Table", clone.GetTableName().Name); Assert.Equal("A1", clone.Annotations.Single().Key); Assert.Equal("V1", clone.Annotations.Single().Value); configuration.ToTable("AnotherTable"); configuration.SetAnnotation("A2", "V2"); Assert.Equal("Table", clone.GetTableName().Name); Assert.Equal("A1", clone.Annotations.Single().Key); Assert.Equal("V1", clone.Annotations.Single().Value); }