abp icon indicating copy to clipboard operation
abp copied to clipboard

AggregateRoot.ExtraProperties could not be mapped Ef Core

Open ryoldash opened this issue 7 years ago • 6 comments

#247, #641 IHasExtraProperties implementation needs revision for ef core.

Error occured in https://abp.io/documents/abp/latest/Tutorials/AspNetCore-Mvc/Part-I tutorial.

Error details after running add-migration: The property 'Book.ExtraProperties' could not be mapped, because it is of type 'Dictionary<string, object>' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

ryoldash avatar Dec 23 '18 19:12 ryoldash

Oh, the aggregate root change has affected it. We will update the tutorial in a short time. Thank you for reporting this.

hikalkan avatar Dec 23 '18 19:12 hikalkan

This will be automatic in the next release: https://github.com/abpframework/abp/issues/682

hikalkan avatar Dec 24 '18 13:12 hikalkan

Whose try to upgrade project, i have done successfully by re-creating migrations at the final and just copied the first initial, designer and snapshot from renew created project from abp.io

Because homehow, i couldn't make new migrations was having an error called

One or more errors occurred. (Invalid column name 'ConcurrencyStamp'.
Invalid column name 'ExtraProperties'.)

ugurozturk avatar Dec 27 '18 20:12 ugurozturk

Hi, i have the same error, when i run Add-Migration on EntityFrameworkCore.DbMigration project,

am i wrong with prepare Entity Class?

My Entity Classes are here,

public class EAInvoiceMaster: AggregateRoot { protected EAInvoiceMaster() {

    }
    public string StationCode { get; set; }
    public string OrderNumber { get; set; }
    public DateTime OrderDate { get; set; }
    public string LicensePlate { get; set; }
 public virtual ICollection<EAInvoiceDetail> EAInvoiceDetail { get; set; }
  
    public EAInvoiceMaster(Guid id,string stationCode, string orderNumber, DateTime orderDate, string licensePlate):base(id)
    {
        StationCode = stationCode;
        OrderNumber = orderNumber;
        OrderDate = orderDate;
        LicensePlate = licensePlate;
    }

}

public class EAInvoiceDetail:AggregateRoot { protected EAInvoiceDetail() {

    }
    public Guid MasterId { get; set; }
    public int LineNumber { get; set; }
    public string ServiceType { get; set; }
    public decimal Quantity { get; set; }
    public decimal UnitPrice { get; set; }

[ForeignKey("MasterId")]
    public virtual EAInvoiceMaster EAInvoiceMaster { get; set; }

 public EAInvoiceDetail(Guid id,Guid masterId,int lineNumber,string serviceType,decimal quantity,decimal unitPrice):base(id)
    {
        MasterId = masterId;
        LineNumber = lineNumber;
        ServiceType = serviceType;
        Quantity = quantity;
        UnitPrice = unitPrice;
}

The property 'EAInvoiceDetail.ExtraProperties' could not be mapped, because it is of type 'Dictionary<string, object>' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

doganc avatar Mar 03 '20 19:03 doganc

  1. Did you inherit AbpDbContext?
  2. Did you override OnModelCreating? If yes, then did you call the base method?

acjh avatar Mar 04 '20 01:03 acjh

Hi, it was my mistake, I forgot the ConfigureExtraProperties() in ConfigureExtension. The problem solved. Thanks for your help.

doganc avatar Mar 04 '20 12:03 doganc