NopCommerce 4.3 - SqlException: Invalid object name 'Dinosaurs'

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
I ran into this issue that's got me stumped at the moment. I'm receiving the above error message when I visit a page that belongs to a plugin that I created even though I actually have a table in the database named "Dinosaurs". I've looked everywhere I could think of and am unable to find a solution. Am I missing something?

The BaseEntity code:

public class Dinosaurs: BaseEntity
    {
        public int DinosaurId { get; set; }
        public string DinosaurSrc { get; set; }
    }

Thanks!
3 年 前
TimJ012 wrote:
I ran into this issue that's got me stumped at the moment. I'm receiving the above error message when I visit a page that belongs to a plugin that I created even though I actually have a table in the database named "Dinosaurs". I've looked everywhere I could think of and am unable to find a solution. Am I missing something?

The BaseEntity code:

public class Dinosaurs: BaseEntity
    {
        public int DinosaurId { get; set; }
        public string DinosaurSrc { get; set; }
    }

Thanks!


Do you have a DinosaursBuilder class? I think this is needed to wire-up your object to the underlying db table

similar to the OrderBuilder class below, as an example...


  public partial class OrderBuilder : NopEntityBuilder<Order>
    {
        #region Methods

        /// <summary>
        /// Apply entity configuration
        /// </summary>
        /// <param name="table">Create table expression builder</param>
        public override void MapEntity(CreateTableExpressionBuilder table)
        {
            table
                .WithColumn(nameof(Order.CustomOrderNumber)).AsString(int.MaxValue).NotNullable()
                .WithColumn(nameof(Order.BillingAddressId)).AsInt32().ForeignKey<Address>(onDelete: Rule.None)
                .WithColumn(nameof(Order.CustomerId)).AsInt32().ForeignKey<Customer>(onDelete: Rule.None)
                .WithColumn(nameof(Order.PickupAddressId)).AsInt32().Nullable().ForeignKey<Address>(onDelete: Rule.None)
                .WithColumn(nameof(Order.ShippingAddressId)).AsInt32().Nullable().ForeignKey<Address>(onDelete: Rule.None);
        }

        #endregion
    }
3 年 前
Thanks for your reply, Jon. After creating a builder class as you suggested the error went away. I think in nop 3.9 my goto solution for this was always due to the actual table being missing from the database, so that's why I was stumped.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.