Saving entity output

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
edowney
Posts: 14
Joined: Thu 07 Mar 2013 13:10

Saving entity output

Post by edowney » Thu 07 Mar 2013 13:22

Hi Folks,

I'm playing around with the trial version to see if it meets my needs. So far I really like it however I have one major issue. In my existing application each entity has its own directory in which the .cs file is stored. So for instance the Domain.Address.Address entity is stored in a directory called Address in the Domain project. It looks like you can specify where the entities are stored in the templates properties but it looks like you can only specify a directory to dump it all. Is that as flexible as it gets?

Thanx!

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Saving entity output

Post by Shalex » Tue 12 Mar 2013 16:11

edowney wrote: In my existing application each entity has its own directory in which the .cs file is stored.
You should modify a predefined template (right click on it > Copy to Model Folder).
Assuming that you are working with Devart Entity Model (*.edml) and its EntityObject template, open the template and implement the following changes:

1. Replace

Code: Select all

  foreach (EntityClass cls in model.Classes) {

    if (FilePerClass) {
      string rootFileName = baseFileName + "." + cls.Name;
      if (GeneratePartialClass) {
        output.Extension = ".cs";
        output.PushOutputRedirection(EntitiesOutput, "", rootFileName, OverwriteMode.None);
        GenerateFileHeader(false);
with

Code: Select all

  foreach (EntityClass cls in model.Classes) {

    OutputInfo classOutput = new OutputInfo();
    
    if (string.IsNullOrEmpty(EntitiesOutput.Project)){
      classOutput.DestinationFolder = Path.Combine(EntitiesOutput.DestinationFolder, cls.Name);
      Directory.CreateDirectory(classOutput.DestinationFolder);
    }
    else {
      classOutput.Project = EntitiesOutput.Project;
      classOutput.ProjectFolder = Path.Combine(EntitiesOutput.ProjectFolder, cls.Name);
    }

    if (FilePerClass) {
      string rootFileName = baseFileName + "." + cls.Name;
      if (GeneratePartialClass) {
        output.Extension = ".cs";
        output.PushOutputRedirection(classOutput, "", rootFileName, OverwriteMode.None);
        GenerateFileHeader(false);
2. Replace

Code: Select all

      if (GeneratePartialClass)
        output.PushOutputRedirection(EntitiesOutput, rootFileName, rootFileName + 
".Generated");
      else
        output.PushOutputRedirection(EntitiesOutput, rootFileName);
with

Code: Select all

      if (GeneratePartialClass)
        output.PushOutputRedirection(classOutput, rootFileName, rootFileName + ".Generated");
      else
        output.PushOutputRedirection(classOutput, rootFileName);
Notes:
1. Set the File Per Class property of the template to True.
2. If you are using Entity Developer which is integrated in Visual Studio, you should explicitly assign a value to the EntitiesOutput.Project property of the template.

Post Reply