Guest User

Untitled

a guest
Apr 16th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. dotnet add package Microsoft.EntityFrameworkCore.Design
  2. dotnet add package MySql.Data.EntityFrameworkCore.Design
  3.  
  4. <ItemGroup>
  5. <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
  6. </ItemGroup>
  7.  
  8. MySql.Data.EntityFrameworkCore.Design
  9. Microsoft.EntityFrameworkCore.Tools
  10.  
  11. Scaffold-DbContext `"server=localhost;port=3306;user=root;password=mypass;database=sakila" MySql.Data.EntityFrameworkCore -OutputDir sakila -f`
  12.  
  13. RunScript(migrationBuilder, @"PathToYouScript");
  14.  
  15. private void RunScript(MigrationBuilder migrationBuilder, string scriptFilePath)
  16. {
  17. var migratorPath = Path.Combine("..", scriptFilePath);
  18.  
  19. if (!File.Exists(migratorPath))
  20. {
  21. migratorPath = Path.Combine("..", "..", "..", "..", scriptFilePath);
  22. }
  23.  
  24. migrationBuilder.Sql(File.ReadAllText(migratorPath));
  25. }
Add Comment
Please, Sign In to add comment