protected virtual IEnumerable <MigrationOperation> Diff( IEntityType source, IEntityType target, ModelDifferContext diffContext) { var sourceExtensions = MetadataExtensions.Extensions(source); var targetExtensions = MetadataExtensions.Extensions(target); var schemaChanged = sourceExtensions.Schema != targetExtensions.Schema; var renamed = sourceExtensions.Table != targetExtensions.Table; if (schemaChanged || renamed) { yield return(new RenameTableOperation { Schema = sourceExtensions.Schema, Name = sourceExtensions.Table, NewSchema = schemaChanged ? targetExtensions.Schema : null, NewName = renamed ? targetExtensions.Table : null }); } diffContext.AddMapping(source, target); var operations = Diff(source.GetPropertiesInHierarchy(), target.GetPropertiesInHierarchy(), diffContext) .Concat(Diff(source.GetKeys(), target.GetKeys(), diffContext)) .Concat(Diff(source.GetIndexesInHierarchy(), target.GetIndexesInHierarchy(), diffContext)); foreach (var operation in operations) { yield return(operation); } }
protected virtual IEnumerable <MigrationOperation> Diff( IEnumerable <IProperty> source, IEnumerable <IProperty> target, ModelDifferContext diffContext) => DiffCollection( source, target, (s, t) => { diffContext.AddMapping(s, t); return(Diff(s, t)); }, t => Add(t), Remove, (s, t) => string.Equals(s.Name, t.Name, StringComparison.OrdinalIgnoreCase), (s, t) => string.Equals( MetadataExtensions.Extensions(s).Column, MetadataExtensions.Extensions(t).Column, StringComparison.OrdinalIgnoreCase));