here is the code 
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Ardalis.GuardClauses;
using dddSimpleInvoice.Core.Events;
using dddSimpleInvoiceL.SharedKernel;
using dddSimpleInvoiceL.SharedKernel.Interfaces;

namespace dddSimpleInvoice.Core.Entities
{

 public class Invoice : BaseEntityEv, IAggregateRoot
 {
 [Key]
 public Guid InvoiceId { get; private set; }

 public string DeliveryAddressId { get; private set; }

 public string InvoiceCode { get; private set; }

 public DateTime InvoiceDate { get; private set; }

 public string? CustomerPurchaseOrderNumber { get; private set; }

 public bool IsCreditNote { get; private set; }

 public string? CreditNoteReason { get; private set; }

 public string? Comments { get; private set; }

 public string? DeliveryInstructions { get; private set; }

 public string? InternalComments { get; private set; }

 public Guid LastEditedBy { get; private set; }

 public DateTime LastEditedWhen { get; private set; }

 public DateTime CreateDate { get; private set; }

 public DateTime? DueDate { get; private set; }

 public DateTime? ShipDate { get; private set; }

 public DateTime? DateInvoiced { get; private set; }

 public int InvoiceStatus { get; private set; }

 public decimal? TotalSale { get; private set; }

 public decimal? TotalSaleTax { get; private set; }

 public void SetDeliveryAddressId(string deliveryAddressId)
 {
 DeliveryAddressId = deliveryAddressId;
 }
 public void SetInvoiceCode(string invoiceCode)
 {
 InvoiceCode = Guard.Against.NullOrEmpty(invoiceCode, nameof(invoiceCode));
 }

 public void UpdateCustomerForInvoice(Guid newCustomerId)
 {
 Guard.Against.NullOrEmpty(newCustomerId, nameof(newCustomerId));
 if (newCustomerId == CustomerId)
 {
 return;
 }

 CustomerId = newCustomerId;
 }

 public void SetCustomerPurchaseOrderNumber(string customerPurchaseOrderNumber)
 {
 CustomerPurchaseOrderNumber = customerPurchaseOrderNumber;
 }
 public void SetCreditNoteReason(string creditNoteReason)
 {
 CreditNoteReason = creditNoteReason;
 }
 public void SetComments(string comments)
 {
 Comments = comments;
 }
 public void SetDeliveryInstructions(string deliveryInstructions)
 {
 DeliveryInstructions = deliveryInstructions;
 }
 public void SetInternalComments(string internalComments)
 {
 InternalComments = internalComments;
 }
 public virtual Customer Customer { get; private set; }

 public Guid CustomerId { get; private set; }

 private readonly List \_invoiceDetails = new();

 public IEnumerable InvoiceDetails => \_invoiceDetails.AsReadOnly();
 public void AddNewInvoiceDetail(InvoiceDetail invoiceDetail)
 {
 Guard.Against.Null(invoiceDetail, nameof(invoiceDetail));
 Guard.Against.NullOrEmpty(invoiceDetail.InvoiceDetailId, nameof(invoiceDetail.InvoiceDetailId));
 Guard.Against.DuplicateInvoiceDetail(\_invoiceDetails, invoiceDetail, nameof(invoiceDetail));
 \_invoiceDetails.Add(invoiceDetail);
 }

 public void DeleteInvoiceDetail(InvoiceDetail invoiceDetail)
 {
 Guard.Against.Null(invoiceDetail, nameof(invoiceDetail));
 var invoiceDetailToDelete = \_invoiceDetails
 .Where(id => id.InvoiceDetailId == invoiceDetail.InvoiceDetailId)
 .FirstOrDefault();
 if (invoiceDetailToDelete != null)
 {
 \_invoiceDetails.Remove(invoiceDetailToDelete);
 }
 }

 private Invoice() {} // EF required

 [SetsRequiredMembers]
 public Invoice(Guid invoiceId, Guid customerId, string? deliveryAddressId, string invoiceCode, DateTime invoiceDate, string? customerPurchaseOrderNumber, bool isCreditNote, string? creditNoteReason, string? comments, string? deliveryInstructions, string? internalComments, System.Guid lastEditedBy, DateTime lastEditedWhen, DateTime createDate, DateTime? dueDate, DateTime? shipDate, DateTime? dateInvoiced, int invoiceStatus, decimal? totalSale, decimal? totalSaleTax)
 {
 InvoiceId = Guard.Against.NullOrEmpty(invoiceId, nameof(invoiceId));
 CustomerId = Guard.Against.NullOrEmpty(customerId, nameof(customerId));
 DeliveryAddressId = deliveryAddressId;
 InvoiceCode = Guard.Against.NullOrWhiteSpace(invoiceCode, nameof(invoiceCode));
 InvoiceDate = Guard.Against.OutOfSQLDateRange(invoiceDate, nameof(invoiceDate));
 CustomerPurchaseOrderNumber = customerPurchaseOrderNumber;
 IsCreditNote = Guard.Against.Null(isCreditNote, nameof(isCreditNote));
 CreditNoteReason = creditNoteReason;
 Comments = comments;
 DeliveryInstructions = deliveryInstructions;
 InternalComments = internalComments;
 LastEditedBy = Guard.Against.NullOrEmpty(lastEditedBy, nameof(lastEditedBy));
 LastEditedWhen = Guard.Against.OutOfSQLDateRange(lastEditedWhen, nameof(lastEditedWhen));
 CreateDate = Guard.Against.OutOfSQLDateRange(createDate, nameof(createDate));
 DueDate = dueDate;
 ShipDate = shipDate;
 DateInvoiced = dateInvoiced;
 InvoiceStatus = Guard.Against.NegativeOrZero(invoiceStatus, nameof(invoiceStatus));
 TotalSale = totalSale;
 TotalSaleTax = totalSaleTax;

 }

 }
}
코드는 다음과 같습니다. using System;using System.Collections.Generic;using System.ComponentModel.DataAnnotations;using System.Diagnostics.CodeAnalysis;using System.Linq;using Ardalis.GuardClauses;using dddSimpleInvoice.Core.Events;사용 dddSimpleInvoiceL.SharedKernel;사용 dddSimpleInvoiceL.SharedKernel.Interfaces;네임스페이스 dddSimpleInvoice.Core.Entities{ public class Invoice : BaseEntityEv, IAggregateRoot { [Key] public Guid InvoiceId { get; private set; } public string DeliveryAddressId { get; private set; } public string InvoiceCode { get; private set; } public DateTime InvoiceDate { get; private set; } 공개 문자열? CustomerPurchaseOrderNumber { get; private set; } public bool IsCreditNote { get; private set; } 공개 문자열? CreditNoteReason { get; private set; } 공개 문자열? Comments { get; private set; } public string? DeliveryInstructions { get; private set; } 공개 문자열? InternalComments { get; private set; } public Guid LastEditedBy { get; private set; } public DateTime LastEditedWhen { get; private set; } public DateTime CreateDate { get; private set; } public DateTime? DueDate { get; private set; } public DateTime? ShipDate { get; private set; } public DateTime? DateInvoiced { get; private set; } public int InvoiceStatus { get; private set; } public decimal? TotalSale { get; private set; } public decimal? TotalSaleTax { get; private set; } public void SetDeliveryAddressId(문자열 deliveryAddressId) { 배송지 주소 = 배송지 주소; } public void SetInvoiceCode(문자열 invoiceCode) { InvoiceCode = Guard.Against.NullOrEmpty(invoiceCode, nameof(invoiceCode)); } public void UpdateCustomerForInvoice(Guid newCustomerId) { Guard.Against.NullOrEmpty(newCustomerId, nameof(newCustomerId)); if (newCustomerId == CustomerId) { return; } CustomerId = newCustomerId; } public void SetCustomerPurchaseOrderNumber(문자열 customerPurchaseOrderNumber) { 고객구매주문번호 = 고객구매주문번호; } public void SetCreditNoteReason(string creditNoteReason) { CreditNoteReason = creditNoteReason; } public void SetComments(문자열 코멘트) { Comments = 코멘트; } public void SetDeliveryInstructions(문자열 deliveryInstructions) { 배달 지침 = 배달 지침; } public void SetInternalComments(문자열 internalComments) { InternalComments = 내부 코멘트; } public virtual Customer Customer { get; private set; } public Guid CustomerId { get; private set; } 비공개 읽기 전용 목록 \_invoiceDetails = new(); public IEnumerable InvoiceDetails => \_invoiceDetails.AsReadOnly(); public void AddNewInvoiceDetail(InvoiceDetail invoiceDetail) { Guard.Against.Null(invoiceDetail, nameof(invoiceDetail)); Guard.Against.NullOrEmpty(invoiceDetail.InvoiceDetailId, nameof(invoiceDetail.InvoiceDetailId)); Guard.Against.DuplicateInvoiceDetail(\_invoiceDetails, invoiceDetail, nameof(invoiceDetail)); \_invoiceDetails.Add(invoiceDetail); } public void DeleteInvoiceDetail(InvoiceDetail invoiceDetail) { Guard.Against.Null(invoiceDetail, nameof(invoiceDetail)); var invoiceDetailToDelete = \_invoiceDetails .Where(id => id.InvoiceDetailId == invoiceDetail.InvoiceDetailId) .FirstOrDefault(); if (invoiceDetailToDelete != null) { \_invoiceDetails.Remove(invoiceDetailToDelete); } } private Invoice() {} // EF 필수 [SetsRequiredMembers] public Invoice(Guid invoiceId, Guid customerId, string? deliveryAddressId, string invoiceCode, DateTime invoiceDate, string? customerPurchaseOrderNumber, bool isCreditNote, string? creditNoteReason, string? comments, string? 배송지시, 문자열? 내부 코멘트, System.Guid lastEditedBy, 날짜 시간 lastEditedWhen, 날짜 시간 createDate, 날짜 시간? 기한 날짜, 날짜 시간? 배송 날짜, 날짜 시간? 날짜 인보이스, int 인보이스 상태, 숫자? 총판매액, 숫자? 총판매세액) { InvoiceId = Guard.Against.NullOrEmpty(invoiceId, nameof(invoiceId)); CustomerId = Guard.Against.NullOrEmpty(customerId, nameof(customerId)); 배송지 주소 = 배송지 주소; 송장 코드 = Guard.Against.NullOrWhiteSpace(송장 코드, 이름 오브(송장 코드)); 인보이스 날짜 = Guard.Against.OutOfSQLDateRange(인보이스 날짜, 이름 오브(인보이스 날짜)); CustomerPurchaseOrderNumber = 고객 구매 주문 번호; IsCreditNote = Guard.Against.Null(isCreditNote, nameof(isCreditNote)); CreditNoteReason = 신용 메모 이유; Comments = 댓글; 배달 지침 = 배달 지침; 내부 코멘트 = 내부 코멘트; LastEditedBy = Guard.Against.NullOrEmpty(lastEditedBy, nameof(lastEditedBy)); LastEditedWhen = Guard.Against.OutOfSQLDateRange(lastEditedWhen, nameof(lastEditedWhen)); CreateDate = Guard.Against.OutOfSQLDateRange(createDate, nameof(createDate)); DueDate = dueDate; ShipDate = shipDate; DateInvoiced = dateInvoiced; InvoiceStatus = Guard.Against.NegativeOrZero(invoiceStatus, nameof(invoiceStatus)); 총판매액 = 총판매액; 총판매세 = 총판매세; } }}