Creating POCO classes in a single file using DbContext

My only experience so far with EF is the Legacy EF4.0 project, in which POCO classes were created in a single CS file. This allowed us to add Partial Classes to the same folder with EDMX, tt, etc. files.

I just generated new POCO classes from EF5 using DbContext, and I noticed that each class is in its own file.

I dig into the TT file, and I understand why it does this:

foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection)) { fileManager.StartNewFile(entity.Name + ".cs"); ... 

Is there a parameter somewhere that I can change so that these POCO classes are generated in a single file, or will I have to change the TT file to do this?

+4
source share
1 answer

You need to delete the call in StartNewFile, but why do you need it? Is this required in the same file, because for partial classes to work correctly, the only thing that matters is that the namespaces are the same and that both class definitions are in the same assembly. The folder structure does not matter.

0
source

All Articles