Error Cannot create a DbSet for 'GiftCardUsageHistory' from buld of NOPCOMMERCE 4.1

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 anni tempo fa
Hello,

is problem with edit orders, print invoice from order set status at Order > Billing & Shipping.
After click to edit order NOP go down. Back button worked, but is unable edit order.

At Log show still same problem   >   Cannot create a DbSet for 'GiftCardUsageHistory' because this type is not included in the model for the context

System.InvalidOperationException: Cannot create a DbSet for 'GiftCardUsageHistory' because this type is not included in the model for the context.

It is probably relic from previous version.


Can me someone help with this ?

Petr
5 anni tempo fa
Anyone have same problem ?
5 anni tempo fa
Yes we have.
5 anni tempo fa
We created partial class of NopObjectContext and put there this


    public partial class NopObjectContext
    {
        public DbSet<GiftCard> GiftCards { get; set; }

        public DbSet<GiftCardUsageHistory> GiftCardUsageHistories { get; set; }
    }


And it seems to work.

Rudolf
5 anni tempo fa
rkotulan wrote:
We created partial class of NopObjectContext and put there this...

Rudolf


Many thanks. It´s working.

Jakub
4 anni tempo fa
Please can you write more (where did you add partial class)?
4 anni tempo fa
Next to orginal one. You can name it NopObjectContext.custom.cs
4 anni tempo fa
Thank you for quick help, it works.
4 anni tempo fa
I had this same issue in a plugin I was creating and found the solution here: https://www.nopcommerce.com/boards/topic/11295/the-entity-type-taxratebycity-is-not-part-of-the-model-for-the-current-context#45961
2 anni tempo fa
Problem :
it Could be a Main DbContext calling in the class and our own model which are not present in a main DbContext class so error will be occure.
Solution :
Ok,
let me Explain.
When we are using a Plugin then make sure that which model we are passing.
it should be a our own Objectcontext Or DbContext.
this Context class should be in your plugin.
then we can Create our Objectcontext or DbContext object using constructor in our new class.

hope,
it Would help to everyone who are facing this issues.....
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.