EntityFramework反向POCO代码首先生成单独的文件夹

时间:2014-07-09 06:19:45

标签: asp.net sql-server code-first poco reverse

EntityFramework Reverse POCO Code First Generator执行这样的代码生成 default generated classes 我们可以通过更改tt文件为存储库,接口,配置和POCO实体创建单独的文件夹。目前,所有类都在应用程序的根目录上生成。我们可以用这样的文件夹创建类。 expected way to generate

1 个答案:

答案 0 :(得分:3)

使用这些命名空间指定不同元素现在的位置。这些甚至可能在不同的组件中。 请注意,这不会在这些位置创建文件,只会添加using语句来说明它们的位置。

如果您有订阅,我会在plural sight course

上显示其工作原理

这样做的方法是添加" EntityFramework反向POCO代码第一生成器"进入每个这些文件夹。 然后将.tt设置为仅通过设置

生成所需的相关部分
 ElementsToGenerate = Elements.Poco; in your Entity folder,
 ElementsToGenerate = Elements.Context | Elements.UnitOfWork; in your Context folder,
 ElementsToGenerate = Elements.PocoConfiguration; in your Maps folder.
 PocoNamespace = "YourProject.Entities";
 ContextNamespace = "YourProject.Context";
 UnitOfWorkNamespace = "YourProject.Context";   
 PocoConfigurationNamespace = "YourProject.Maps";
相关问题