protected override IEnumerable<MigrationOperation> Diff(IProperty source, IProperty target) { var operations = base.Diff(source, target).ToList(); var sourceValueGenerationStrategy = GetValueGenerationStrategy(source); var targetValueGenerationStrategy = GetValueGenerationStrategy(target); var alterColumnOperation = operations.OfType<AlterColumnOperation>().SingleOrDefault(); if (alterColumnOperation == null && (source.SqlServer().ComputedExpression != target.SqlServer().ComputedExpression || sourceValueGenerationStrategy != targetValueGenerationStrategy)) { alterColumnOperation = new AlterColumnOperation { Schema = source.EntityType.Relational().Schema, Table = source.EntityType.Relational().Table, Name = source.Relational().Column, Type = TypeMapper.GetTypeMapping(target).StoreTypeName, IsNullable = target.IsNullable, DefaultValue = target.Relational().DefaultValue, DefaultExpression = target.Relational().DefaultExpression }; operations.Add(alterColumnOperation); } if (alterColumnOperation != null) { if (targetValueGenerationStrategy == SqlServerValueGenerationStrategy.Identity) { alterColumnOperation[SqlServerAnnotationNames.Prefix + SqlServerAnnotationNames.ValueGeneration] = targetValueGenerationStrategy.ToString(); } if (target.SqlServer().ComputedExpression != null) { alterColumnOperation[SqlServerAnnotationNames.Prefix + SqlServerAnnotationNames.ColumnComputedExpression] = target.SqlServer().ComputedExpression; alterColumnOperation.IsDestructiveChange |= source.SqlServer().ComputedExpression == null; } } return operations; }
public override void Generate(AlterColumnOperation operation, IModel model, SqlBatchBuilder builder) { throw new NotImplementedException(); }