Domanda

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? enter image description here

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top