Reputation: 410
I am using NopCommerce.
How can I create new table in NopCommerce?
I have followed these steps.
Create The Entity Class (e.g Entity.cs)
Path : Nop/Core/Domain/Entity.cs
Create The Mapping Class (e.g EntityMap.cs
)
Path : Nop/Data/Mapping/EntityMap.cs
Create a Model for MVC (e.g EntityModel.cs
)
Path : Nop/Admin/Models/EntityModel.cs OR Nop/Web/Models/EntityModel.cs
Create a validator for model (e.g EntityValidator.cs
)
Path : Nop/Admin/Validators/EntityValidator.cs OR Nop/Web/Validators/EntityValidator.cs
Create A Mapping Configuration On AutoMapperStartupTask.cs
for Entity and Model
Path : Nop/Admin/Infrastructure OR Nop/Web/Infrastructure
Apply Mapping between Model and Entity on MappingExtensions.cs
Path : Nop/Admin
OR Nop/Web
Create a service class and service interface (e.g EntityService.cs
, IEntityService.cs
)
Path : Nop/Services/EntityService.cs AND Nop/Services/IEntityService.cs
Finally Create Controller and View for given model
But new table is not created. so what should be problem?
Upvotes: 2
Views: 4893
Reputation: 616
Open this path ~\Nop.Web.Framework and open DependencyRegistrar.cs and register your service and interface like this
// UserMaster
builder.RegisterType<EntityService>().As<IEntityService ().InstancePerLifetimeScope();
Create table in NopCommerce database and give name "Entity".
Note: Manually create table in database is necessary.
Finally create new controller and its View
If you want to get to more detail, Click here!
Upvotes: 1
Reputation: 10694
I think you have found above thing at
http://pl-developer.blogspot.in/2013/02/how-to-add-new-table-with-model-map-to.html
Below blogger has written
as Nop Commerce uses the very first release of MVC3, database migration is not supported and you must make changes to database tables by hand. Because MVC code-first must drop and recreate your database for reflecting changes to your database.
Upvotes: 2