nopCommerce 4.10 reference for ToTable

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
I am new to nopCommerce development and trying to get my first plugin up and running. when I am doing my data mapping the ToTable is not recognize (see screenshots).





I am not sure which reference I am missing any help would be appreciated (name and path).

I'm on nopCommerce 4.10.
5 years ago
No screen shots attached
5 years ago
here see if I paste the link to the screenshot without adding image

http://prntscr.com/m4nnzf

http://prntscr.com/m4no6v
5 years ago
You need to add builder. in front

i.e.

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<ProductTemplate> builder)
        {
            builder.ToTable(nameof(ProductTemplate));
            builder.HasKey(template => template.Id);

            builder.Property(template => template.Name).HasMaxLength(400).IsRequired();
            builder.Property(template => template.ViewPath).HasMaxLength(400).IsRequired();

            base.Configure(builder);
        }
5 years ago
Thanks for your reply, I tried that and this error came up

Severity  Code  Description  Project  File  Line  Suppression State
Error  CS1061  'EntityTypeBuilder<ProductSourceRecord>' does not contain a definition for 'ToTable' and no accessible extension method 'ToTable' accepting a first argument of type 'EntityTypeBuilder<ProductSourceRecord>' could be found (are you missing a using directive or an assembly reference?)  

here is my full code

using Nop.Plugin.Widgets.ProductSourcing.Domain;
using Nop.Data.Mapping;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Nop.Data;

namespace Nop.Plugin.Widgets.ProductSourcing.Data
{
    public partial class ProductSourceMap : NopEntityTypeConfiguration<ProductSourceRecord>
    {
        public override void Configure(EntityTypeBuilder<ProductSourceRecord> builder)
        {
            builder.ToTable("Product_Sourcing");

            base.Configure(builder);
        }
    }
}
5 years ago
Clearly there is some definiton or something missing somewhere

When I added a new table I Searched for "ProductTemplate" and copied and pasted all existing relevant code and changed the code to make a new entity "ProductTypeExtension"

I did all this in the main program

Maybe you should do this first and get it working before moving the new code into a pluggin
5 years ago
use builder.ToTable name at the time of mapping.

add domain class name as parameter
e.g. builder.ToTable(nameof(BackInStockSubscription));

and for more detail refer any of one mapping class of nopCommerce.
5 years ago
Thanks Yidna will go down that route.

cheers
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.