【问题标题】:AutoMapper.Collection.EFCore - Error thrown during ConfigurationAutoMapper.Collection.EFCore - 配置期间抛出错误
【发布时间】:2018-11-21 18:24:47
【问题描述】:

AutoMapper.Collection.EFCore 今天刚刚在 Nuget 上发布,我现在正在尝试使用。

我已经按照Docs:设置好了

在 startup.cs 中,在 ConfigureServices 方法中:

Mapper.Initialize(cfg =>
{
    cfg.AddCollectionMappers();
    cfg.SetGeneratePropertyMaps<GenerateEntityFrameworkCorePrimaryKeyPropertyMaps<ApplicationDbContext>>();
});

抛出此异常:

InvalidOperationException: Use AddEntityFrameworkCoreKeys instead of using SetGeneratePropertyMaps.

但是,我在cfg 上没有找到任何这样的方法

【问题讨论】:

    标签: automapper automapper-collections-ef-core


    【解决方案1】:

    重命名为 UseEntityFrameworkCoreModel。您应该报告它,以便他们更改消息。

    【讨论】:

    • 我已提交要修复的问题。
    • 我应该使用的完整语法是什么? cfg.UseEntityFrameworkCoreModel&lt;DbContext&gt;(services); 抛出异常 'No service for type 'Microsoft.EntityFrameworkCore.DbContext' has been registered.'
    • 我不知道,但我想注册 DbContext 是你的工作。检查 repo 中的测试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-25
    • 2022-06-17
    • 2020-09-10
    • 2018-06-15
    • 1970-01-01
    • 2021-11-05
    • 2014-12-11
    相关资源
    最近更新 更多