看起来没有办法使用 edmgen 来做到这一点。使用反射器,我发现 edmgen 用于System.Data.Entity.Design.dll
完成其工作,您可以像这样以编程方式排除数据库视图和函数:
var essg = new EntityStoreSchemaGenerator("System.Data.SqlClient", ConfigurationManager.ConnectionStrings["MST"].ConnectionString, "EFModel");
essg.GenerateForeignKeyProperties = true;
var filter1 = new EntityStoreSchemaFilterEntry(null, null, null, EntityStoreSchemaFilterObjectTypes.Table, EntityStoreSchemaFilterEffect.Allow);
var filter2 = new EntityStoreSchemaFilterEntry(null, null, null, EntityStoreSchemaFilterObjectTypes.View, EntityStoreSchemaFilterEffect.Exclude);
var filter3 = new EntityStoreSchemaFilterEntry(null, null, null, EntityStoreSchemaFilterObjectTypes.Function, EntityStoreSchemaFilterEffect.Exclude);
var filters = new EntityStoreSchemaFilterEntry[] { filter1, filter2, filter3 };
var errors1 = essg.GenerateStoreMetadata(filters);