EF核心3:如何迁移Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper?

时间:2019-09-25 18:51:37

标签: c# entity-framework-core entity-framework-core-3.0

EF Core 3中没有

Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper

我正在使用它来支持通过EF Core Migrations安装/卸载sql server约束。

public class MyCSharpHelper : CSharpHelper
{
    public MyCSharpHelper (IRelationalTypeMappingSource relationalTypeMappingSource) : base(relationalTypeMappingSource)
    {

    }

    public override string UnknownLiteral(object value)
    {
        if (value is MyConstraint[] constraints)
        {
            return ConstraintManager.ProcessConstraintLiteral(constraints);
        }
        return base.UnknownLiteral(value);
    }
}

在EF Core 3中应该如何显示?

1 个答案:

答案 0 :(得分:1)

Microsoft.EntityFrameworkCore.Design现在是一个DevelopmentDependency程序包,这意味着它将不会与您的应用程序一起部署,并且您无法在代码中引用它。

如果需要自定义设计时服务,则必须按照以下说明在项目中编辑PackageReference:https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes#microsoftentityframeworkcoredesign-is-now-a-developmentdependency-package