为什么在解决EF6中的Pluralization Service时会出错?

时间:2014-02-28 16:43:31

标签: c# entity-framework

我的Context类中有以下代码。直接来自MSDN post

    private string GetTableName(Type type)
    {
        var pluralizationService = DbConfiguration.DependencyResolver.GetService<IPluralizationService>();
        var result = pluralizationService.Pluralize(type.Name);
        result = Regex.Replace(result, ".[A-Z]", m => m.Value[0] + "_" + m.Value[1]);
        return result.ToUpper();
    }

我得到的错误是The non-generic method 'System.Data.Entity.Infrastructure.DependencyResolution.IDbDependencyResolver.GetService(System.Type, object)' cannot be used with type arguments我在想我要么缺少一个使用条款。或者实体框架6.0.1存在问题。除了System.Data.Entity和System.Data.Entity.Infrastructure.Pluralization之外,我找不到需要包含的库。

1 个答案:

答案 0 :(得分:3)

尝试添加using System.Data.Entity.Infrastructure.DependencyResolution;