コード例 #1
0
        protected virtual void ConfigureProperty(IMutableProperty property, string configuration, string value)
        {
            var propertyAnnotations = property.Npgsql();

            switch (configuration)
            {
            case nameof(RelationalPropertyAnnotations.DefaultValue):
                property.ValueGenerated          = ValueGenerated.OnAdd;
                propertyAnnotations.DefaultValue = int.Parse(value);
                break;

            case nameof(RelationalPropertyAnnotations.DefaultValueSql):
                property.ValueGenerated             = ValueGenerated.OnAdd;
                propertyAnnotations.DefaultValueSql = value;
                break;

            case nameof(RelationalPropertyAnnotations.ComputedColumnSql):
                property.ValueGenerated = ValueGenerated.OnAddOrUpdate;
                propertyAnnotations.ComputedColumnSql = value;
                break;

            case nameof(NpgsqlPropertyAnnotations.ValueGenerationStrategy):
                property.ValueGenerated = ValueGenerated.OnAdd;
                propertyAnnotations.ValueGenerationStrategy = NpgsqlValueGenerationStrategy.SerialColumn;
                break;

            default:
                throw new NotImplementedException();
            }
        }