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

Rudolf


Many thanks. It´s working.

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