Derived Models Common Base Classes

Posts   
 
    
Jon_enabl
User
Posts: 1
Joined: 28-Aug-2025
# Posted on: 28-Aug-2025 19:11:22   

Greetings, it has been a while...

Client wants to basically have a dervied model per microservice. I have a set of base classes that I have for my derived models and now I need those spread across multiple direvied models.

Seems like when I add the additional project ref it sticks after the project generation, but the using statement will get dropped. Is there a way to preserve this using statement to prevent it from getting removed?

After Project Generation

using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Collections.Generic;

namespace ChannelSoft.DTO.PermissionX.DtoClasses
{ 
    /// <summary> DTO class which is derived from the entity 'Permission.Usergroup'.</summary>
    [Serializable]
    [DataContract]
    public partial class UsergroupModel: BaseModel

Before project Generation

using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Collections.Generic;
using ChannelSoft.DTO.Common

namespace ChannelSoft.DTO.PermissionX.DtoClasses
{ 
    /// <summary> DTO class which is derived from the entity 'Permission.Usergroup'.</summary>
    [Serializable]
    [DataContract]
    public partial class UsergroupModel: BaseModel //BaseModel from DTO.Common Project

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39922
Joined: 17-Aug-2003
# Posted on: 29-Aug-2025 08:58:01   

All code gets overwritten, so you can't alter generated files. But, you can add additional namespaces which are then generated into the classes. Load your project into the designer, open the project settings, go to conventions -> Derived models -> your derived model -> Code generation -> Additional namespaces, and specify the namespace there for the element you want to have the namespace be included for, e.g. the root derived element.

Then generate code simple_smile

Frans Bouma | Lead developer LLBLGen Pro