Open Closed

set ID #4819


User avatar
0
shobhit created
  • ABP Framework version: v4.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I have following domain class. i have to create a instance and set the Id property. How i can set Id property. (I understand Id is Private so what will be alternate).

public class MyCloass : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
      [NotNull]
        public virtual string Detail { get; set; }

        [NotNull]
        public virtual string Title { get; set; }

}
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You can consider:

    public class MyCloass : FullAuditedAggregateRoot<Guid>, IMultiTenant
    {
          [NotNull]
          public virtual string Detail { get; set; }
    
          [NotNull]
          public virtual string Title { get; set; }
          
          public void SetId(Guid id)
          {
             Id = id;
          }
    
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.