实体框架核心3.0上的HasDefaultValue()扩展方法在哪里

时间:2019-11-04 20:16:12

标签: c# entity-framework asp.net-core .net-core

此行是警告错误,一旦移至EF 3.0,我找不到HasDefaultValue()扩展方法

using MGame.Core;
using MGame.Model;
using MGame.Model.Enums;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;

namespace MGame.Data.DataContextConfigurations
{
    public class AddressConfiguration : DataContextBaseEntityTypeConfiguration, IEntityTypeConfiguration<Address>
    {
        public void Configure(EntityTypeBuilder<Address> builder)
        {

            builder.Property(e => e.AddressTypeId).IsRequired().HasDefaultValue(0);

也失败了

        builder.ToTable(nameof(AncestorRegionView));

以及

builder.Metadata.IsQueryType = true;

1 个答案:

答案 0 :(得分:0)

我只需要添加对软件包Microsoft.EntityFrameworkCore.Relational的引用:

<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0" />