use*_*582 9 nopcommerce entity-framework-4
我是NopCommerce v2.4的新手,想知道我在哪里编写代码(通过在admin或nop.web部分创建新模型)
Beh*_*ili 20
我花了很多时间来深入研究这个问题的深度.我可以总结解决方案如下:
创建实体类(例如Entity.cs)
路径:Nop/Core/Domain/Entity.cs
创建映射类(例如EntityMap.cs)
路径:Nop/Data/Mapping/EntityMap.cs
为MVC创建模型(例如EntityModel.cs)
路径:Nop/Admin/Models/EntityModel.cs或Nop/Web/Models/EntityModel.cs
为模型创建验证器(例如EntityValidator.cs)
路径:Nop/Admin/Validators/EntityValidator.cs或Nop/Web/Validators/EntityValidator.cs
在AutoMapperStartupTask.cs上为实体和模型创建映射配置
路径:Nop/Admin/Infrastructure或Nop/Web/Infrastructure
在MappingExtensions.cs上应用模型和实体之间的映射
路径:Nop/Admin或Nop/Web
创建服务类和服务接口(例如EntityService.cs,IEntityService.cs)
路径:Nop/Services/EntityService.cs和Nop/Services/IEntityService.cs
注册依赖注入服务
路径:Nop/Web/Framework/DependencyRegistrar.cs
最后为给定模型创建控制器和视图
由于Nop Commerce使用MVC3的第一个版本,因此不支持数据库迁移,您必须手动更改数据库表.因为MVC代码优先必须删除并重新创建数据库以反映对数据库的更改.
如果您想在任何步骤中获得更多详细信息,请告诉我 - 我可以详细描述每个步骤.希望这可以帮助.