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.
Il y a 5 ans
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
Il y a 5 ans
Anyone have same problem ?
Il y a 5 ans
Yes we have.
Il y a 5 ans
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
Il y a 5 ans
rkotulan wrote:
We created partial class of NopObjectContext and put there this...

Rudolf


Many thanks. It´s working.

Jakub
Il y a 4 ans
Please can you write more (where did you add partial class)?
Il y a 4 ans
Next to orginal one. You can name it NopObjectContext.custom.cs
Il y a 4 ans
Thank you for quick help, it works.
Il y a 4 ans
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
Il y a 2 ans
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.