【问题标题】:Piranha cms with MySql食人鱼 cms 与 MySql
【发布时间】:2018-12-13 19:11:43
【问题描述】:

我正在尝试将 pranha cms (5.3.1) 与 MySql 一起使用。这是我在 Startup.cs 文件中使用的代码,但出现此错误:

InvalidOperationException:没有为“Piranha.IApi”类型注册服务。可能是什么问题?

    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.AddMvc(config =>
        {
            config.ModelBinderProviders.Insert(0, new Piranha.Manager.Binders.AbstractModelBinderProvider());
        });
        services.AddPiranhaApplication();
        services.AddPiranhaFileStorage();
        services.AddPiranhaImageSharp();
        services.AddDbContext<Db>(options =>
            options.UseMySql("server=localhost;port=3306;database=piranha-mysql;uid=root;password="));
        services.AddPiranhaManager();
        services.AddPiranhaMemCache();

        return services.BuildServiceProvider();
    }

【问题讨论】:

    标签: asp.net-core piranha-cms


    【解决方案1】:

    您应该使用而不是调用 AddDbContext:

    services.AddPiranhaEF(...);
    

    这两个都注册了 DbContext 和应该使用的 API。

    问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 2014-04-20
      • 2011-04-18
      相关资源
      最近更新 更多