【问题标题】:How to add new table in NopCommerce?如何在 NopCommerce 中添加新表?
【发布时间】:2014-04-04 03:51:22
【问题描述】:

我正在使用 NopCommerce。

如何在 NopCommerce 中创建新表?

我已按照这些步骤操作。

  1. 创建实体类(例如 Entity.cs)

    路径:Nop/Core/Domain/Entity.cs

  2. 创建映射类(例如EntityMap.cs)

    路径:Nop/Data/Mapping/EntityMap.cs

  3. 为 MVC 创建模型(例如 EntityModel.cs)

    路径:Nop/Admin/Models/EntityModel.cs OR Nop/Web/Models/EntityModel.cs

  4. 为模型创建一个验证器(例如EntityValidator.cs)

    路径:Nop/Admin/Validators/EntityValidator.cs OR Nop/Web/Validators/EntityValidator.cs

  5. 在AutoMapperStartupTask.cs 上为实体和模型创建映射配置

    路径:Nop/Admin/Infrastructure OR Nop/Web/Infrastructure

  6. 在MappingExtensions.cs上应用模型和实体之间的映射

    路径:Nop/Admin 或 Nop/Web

  7. 创建服务类和服务接口(例如EntityService.cs,IEntityService.cs)

    路径:Nop/Services/EntityService.cs AND Nop/Services/IEntityService.cs

  8. 最后为给定模型创建控制器和视图

但是没有创建新表。那应该是什么问题?

【问题讨论】:

    标签: c# asp.net-mvc nopcommerce


    【解决方案1】:

    我想你已经在

    找到了上面的东西

    http://pl-developer.blogspot.in/2013/02/how-to-add-new-table-with-model-map-to.html

    下面博主写过

    由于 Nop Commerce 使用 MVC3 的第一个版本,数据库 不支持迁移,您必须更改数据库 手工制作的桌子。因为 MVC 代码优先必须删除并重新创建您的 用于反映数据库更改的数据库。

    【讨论】:

    • 非常感谢。这对我很有帮助。
    【解决方案2】:

    打开这个路径 ~\Nop.Web.Framework 并打开 DependencyRegistrar.cs 并像这样注册你的服务和接口

    // UserMaster
    builder.RegisterType<EntityService>().As<IEntityService ().InstancePerLifetimeScope();
    

    在 NopCommerce 数据库中创建表并命名为“Entity”。

    注意:需要在数据库中手动创建表。

    最后创建新的控制器和它的视图

    如果您想了解更多详情,请点击here!

    【讨论】:

      猜你喜欢
      • 2017-12-05
      • 2012-04-12
      • 2012-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      相关资源
      最近更新 更多