Extend Customer using CustomerExtension new table

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Is it possible to have another new table IE: "CustomerExtension" that will hold new properties for the Customer. (We want to avoid using the same table).


So we have extended the Customer class in Nop.Core:


public partial class Customer
    {
        public string DiscountClass { get; set; }
        public string RepCode { get; set; }
      
    }


We have then extended the existing CustomerMap by creating another partial.


public partial class CustomerMap : NopEntityTypeConfiguration<Customer>
    {
        protected override void PostInitialize()
        {
            this.Map(m =>
            {
                m.Properties(p => new { p.Id, p.DiscountClass, p.RepCode});
                m.ToTable("CustomerExtension");
            });

        }


But this seems not to properly work as we got an exception like so: "An item with the same key has already been added."

Are we doing something wrong in here? We should be able to extend a class in a different database table right ?

Both tables have the same primary key
6 years ago
I think below link will help you
https://stackoverflow.com/questions/3594236/entity-framework-an-item-with-the-same-key-has-already-been-added-error-whe
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.