我有一个 POCO 对象(EF 代码优先)
public class ExampleTestOfDataTypes
{
public string StringProp { get; set; }
}
比我有它的配置类:
public class ExampleTestOfDataTypesConfig : EntityTypeConfiguration<ExampleTestOfDataTypes>
{
public ExampleTestOfDataTypesConfig()
{
ToTable("CustomTableName");
this.Property(m => m.StringProp).HasColumnName("CustomString");
}
}
当我在配置文件中更改新的表名和新的 StringProp 名称时,我如何获得它(考虑到我有 exampleTestOfDataTypesConfig 和 exampleTestOfDataTypes)
谢谢
如果您想知道映射文件中的内容,请尝试此方法:
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);
}
}
它会将所有自定义设置导出到 xml 文件。最好将其命名为.edmx,然后 VS.NET 就可以自动打开它。