2013-05-10 58 views
3

我使用edmgen.exe工具是這樣的:如何使用edmgen.exe生成模型時排除視圖?

"%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 

上面的代碼包含在EF模型的意見。我不希望包含任何意見,類似於下面的屏幕截圖。如何才能做到這一點? enter image description here

回答

6

看起來像沒有辦法使用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); 
+0

謝謝!看起來我可能是世界上想要這樣做的第四人...... – 2015-10-23 13:30:49