Last active
May 25, 2016 15:19
-
-
Save arman-hpp/9944ea0f9b05142185571924c9fc7621 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DbMigrationExtensions | |
{ | |
public static void AlterDataFileSize(this DbMigration dbMigration, int size) | |
{ | |
var sqlMethod = dbMigration.GetType().GetMethod("Sql", BindingFlags.Instance | BindingFlags.NonPublic); | |
sqlMethod.Invoke(dbMigration, new object[] { $@" | |
DECLARE @dbName varchar(100) = (SELECT db_name()) | |
DECLARE @sqlCommand nvarchar(1000) = ('ALTER DATABASE ' + @dbName + ' MODIFY FILE ( NAME = ''' + @dbName +''', SIZE = {size}MB )') | |
EXECUTE sp_executesql @sqlCommand, N'@dbName varchar(100)', @dbName = @dbName | |
", true, null }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment