I am using the edmgen.exe tool like this:
"%windir%\Microsoft.NET\Framework\v4.0.30319\edmgen.exe" /mode:fullgeneration
/c:"Data Source=%datasourceserver%; Initial Catalog=School; Integrated Security=SSPI"
/project:School /entitycontainer:SchoolEntities /namespace:SchoolModel /language:CSharp
above code includes the views in the ef model. I don't want any views to be included, similar to screenshot below. How can this be done?
Looks like there is no way to do this using edmgen. Using reflector, I found that edmgen uses System.Data.Entity.Design.dll
to do its work, and you can exclude the db views & functions programatically like this:
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With