System.Data.Entity.SqlServer.SqlServerMigrationSqlGenerator.ResolveNameConflicts C# (CSharp) Method

ResolveNameConflicts() private static method

Creates a shallow copy of the source CreateTableOperation and the associated AddPrimaryKeyOperation but renames the table and the primary key in order to avoid name conflicts with existing objects.
private static ResolveNameConflicts ( System.Data.Entity.Migrations.Model.CreateTableOperation source ) : System.Data.Entity.Migrations.Model.CreateTableOperation
source System.Data.Entity.Migrations.Model.CreateTableOperation
return System.Data.Entity.Migrations.Model.CreateTableOperation
        private static CreateTableOperation ResolveNameConflicts(CreateTableOperation source)
        {
            DebugCheck.NotNull(source);

            const string suffix = "2";

            var target = new CreateTableOperation(source.Name + suffix)
                             {
                                 PrimaryKey = new AddPrimaryKeyOperation()
                             };

            Debug.Assert(target.PrimaryKey.Name == source.PrimaryKey.Name + suffix);

            source.Columns.Each(c => target.Columns.Add(c));
            source.PrimaryKey.Columns.Each(c => target.PrimaryKey.Columns.Add(c));

            return target;
        }