The entity type PopularToys is not part of the model for the current context.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hello All,

I have created a Plugin and created a table from installation section and want to perform CRUD operations in plugin but this table's entity and model class has to be inside plugin not in Libraries (means independent of Nop.Core and Nop.Data).

Now when I try to fetch this table I get following error:

The entity type PopularToys is not part of the model for the current context.
6 years ago
// Data context
this.RegisterPluginDataContext<YOUR_CONTEXT>(builder, "YOUR_CONTEXT_NAME");

// Override required repository with your custom context
builder
    .RegisterType<EfRepository<YOUR_ENTITY>>()
    .As<IRepository<YOUR_ENTITY>>()
    .WithParameter(ResolvedParameter.ForNamed<IDbContext>("YOUR_CONTEXT_NAME"))
    .InstancePerLifetimeScope();




For more, check this: http://docs.nopcommerce.com/display/en/Plugin+with+data+access
6 years ago
I was facing same issue " Message "The entity type xxxxxxx is not part of the model for the current context." string"

When I was trying to create a new table and try to use CRUD operation using Entity framework. Then I was facing same exception.
For it, I have to create a new file for Table mapping in Library mapping directory.
After that, issue is resolved at my end.
6 years ago
jagdeepsingh wrote:
I was facing same issue " Message "The entity type xxxxxxx is not part of the model for the current context." string"

When I was trying to create a new table and try to use CRUD operation using Entity framework. Then I was facing same exception.
For it, I have to create a new file for Table mapping in Library mapping directory.
After that, issue is resolved at my end.


Make sure column exist in table or column name and entity object name are same in core domain model.
6 years ago
Hello,

Your table field should be in core domain class.

This domain class should register with dependency register.

Your table mapping file also inside plugin context file.

Your context file should register with dependency register

This four thing is well than your CRUD operation working smoothly.

For more information you also refer Google analytics plugin in nopcommerce source code.
6 years ago
Just follow the nopCommerce guides

http://docs.nopcommerce.com/display/en/Plugin+with+data+access
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.