Nopcommerce v3.4 - Add new table - invalid column name 'Hotel_Id'

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 Jahre weitere
Hello,

I have added a new table in the database named 'Hotel' and add the following files in Nop solution:

1. Path : Nop/Core/Domain/Hotel.cs

2. Path : Nop/Data/Mapping/HotelMap.cs    

3. Path : Nop/Admin/Models/HotelModel.cs    

4. Path : Nop/Admin/Infrastructure/AutoMapperStartupTask.cs    

5. Apply Mapping between Model and Entity on MappingExtensions.cs

6. Create a service class and service interface (e.g HotelService.cs , IHotelService.cs)

    Path : Nop/Services/EntityService.cs AND Nop/Services/IEntityService.cs

after running the application, and trying to call _hotelService.InsertHotel(hotel) method
I got the following error :

Invalid column name 'Hotel_Id'. Even though i don't have this column name in db or in Nop solution.

Any help would appreciated.
7 Jahre weitere
omaani wrote:
Hello,

I have added a new table in the database named 'Hotel' and add the following files in Nop solution:

1. Path : Nop/Core/Domain/Hotel.cs

2. Path : Nop/Data/Mapping/HotelMap.cs    

3. Path : Nop/Admin/Models/HotelModel.cs    

4. Path : Nop/Admin/Infrastructure/AutoMapperStartupTask.cs    

5. Apply Mapping between Model and Entity on MappingExtensions.cs

6. Create a service class and service interface (e.g HotelService.cs , IHotelService.cs)

    Path : Nop/Services/EntityService.cs AND Nop/Services/IEntityService.cs

after running the application, and trying to call _hotelService.InsertHotel(hotel) method
I got the following error :

Invalid column name 'Hotel_Id'. Even though i don't have this column name in db or in Nop solution.

Any help would appreciated.

Did you use Hotel object in another domain?
7 Jahre weitere
No I did'not, only in hotel domain.
Below is the code for core domain and map:


namespace Nop.Core.Domain.Hotels
{
    public class Hotel : BaseEntity
    {
        private ICollection<Hotel> _hotels;

        public string Name { get; set; }
        public string Description { get; set; }
        public string General { get; set; }
        public string Activities { get; set; }
        public string Services { get; set; }
        public string Internet { get; set; }
        public string Parking { get; set; }
        public string Checkin { get; set; }
        public string Checkout { get; set; }
        public int Stars { get; set; }

        /// <summary>
        /// Gets or sets the display order
        /// </summary>
        public int DisplayOrder { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the entity is subject to ACL
        /// </summary>
        public bool SubjectToAcl { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
        /// </summary>
        public bool LimitedToStores { get; set; }

        public virtual ICollection<Hotel> Hotels
        {
            get { return _hotels ?? (_hotels = new List<Hotel>()); }
            protected set { _hotels = value; }
        }

    }
}

using Nop.Core.Domain.Hotels;

namespace Nop.Data.Mapping.Hotels
{
    public partial class HotelMap : NopEntityTypeConfiguration<Hotel>
    {
        public HotelMap()
        {
            this.ToTable("Hotel");
            this.HasKey(h => h.Id);            
          
        }
    }
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.