问题
I have a POCO object (EF Code-first)
public class ExampleTestOfDataTypes
{
public string StringProp { get; set; }
}
Than i have its configuration class:
public class ExampleTestOfDataTypesConfig : EntityTypeConfiguration<ExampleTestOfDataTypes>
{
public ExampleTestOfDataTypesConfig()
{
ToTable("CustomTableName");
this.Property(m => m.StringProp).HasColumnName("CustomString");
}
}
How can i get the new Tablename and new StringProp name when i changed it in config file (considering i have ExampleTestOfDataTypesConfig and ExampleTestOfDataTypes)
Thanks
回答1:
If you want to know what's inside the mappings file, try this method:
void ExportMappings(DbContext context, string edmxFile)
{
var settings = new XmlWriterSettings { Indent = true };
using (XmlWriter writer = XmlWriter.Create(edmxFile, settings))
{
System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(context, writer);
}
}
It will export all of your custom settings to an xml file. It's better to name it .edmx and then VS.NET will be able to open it automatically.
来源:https://stackoverflow.com/questions/10738382/ef-codefirst-get-pocos-configuration