Add new field to Address table

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi!

I trying to add new field to Address table:
So i did:
Add this code to  public partial class Address : BaseEntity, ICloneable

public string CIT_Area { get; set; }

And manually create CIT_Area in SQL table

ALTER TABLE [Address] ADD [Test] nvarchar(4000) NULL ;
GO


But I recieve an error that : The model backing the 'NopObjectContext' context has changed since the database was created.
Could u tell me whats wrong?
6 years ago
Hi,

Apologize for my question, but why you do not use custom address attributes? You may find it at the Configuration >> Settings >> Customer settings >> Address form fields tab. In case of upgrade you will not have additional job...

Regards,
Tomasz
6 years ago
maybe in db you add a [TesT] column, not CIT_AREA
6 years ago
Either you add a EF mapping for CIT_Area to column test or rename the field on the database.

Take this

// ... AddressMap.cs

this.Property(x => x.CIT_Area).HasColumnName("Test").IsOptional().HasMaxLength(4000);

5 years ago
Hi all,

I am trying to add a new field to the address table in V4.0. I am attempting to follow the tutorial found here:

http://docs.nopcommerce.com/pages/viewpage.action?pageId=1442499

I figured that it should not be that different from adding a property to another table. But something's not right. Here's what I did:

1) Added the field to Nop.Core\Domain\Common\Address.cs and added the Required and Enabled to the AddressSettings.cs in the same directory.

2) Went into Nop.Data\Common\AddressMap.cs and saw no references to any address fields, so did nothing.

3) Modified the Now.Web\Areas\Admin\Validators\Common\AddressValidator.cs

The problem comes that the documentation falls apart at the View section. Any ide on what is ACTUALLY the way to add a field to the Address Table in V4.0?

Thanks in advance!
J
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.