This file contains 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
dotnet new blazorserver --use-local-db --auth Individual --name Golb |
This file contains 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
docker pull mcr.microsoft.com/mssql/server:2019-latest | |
docker run -d - name sql_server -e ACCEPT_EULA=Y -e SA_PASSWORD=<yourPasswordHere> -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest |
This file contains 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
docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
831295b80b53 mcr.microsoft.com/mssql/server:2019-latest "/opt/mssql/bin/perm…" 3 minutes ago Up 2 seconds 0.0.0.0:1433->1433/tcp sql_server |
This file contains 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
// appsettings.json | |
{ | |
"ConnectionStrings": { | |
"DefaultConnection": "Data Source=localhost,1433;User ID=sa;Password=superSecurePwd123;Connect Timeout=30;Database=GolbDatabase" | |
} | |
... etc | |
} |
This file contains 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
// Startup.cs | |
// Should not user Database.Migrate() in production, instead migrations should be done as part of deployment | |
using (var srvc = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) | |
{ | |
var context = srvc.ServiceProvider.GetService<ApplicationDbContext>(); | |
context.Database.Migrate(); | |
} |
This file contains 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
dotnet tool install --global dotnet-ef |
This file contains 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
// Data/Post.cs | |
using System; | |
namespace Golb.Data | |
{ | |
public class Post | |
{ | |
public int Id { get; set; } | |
public string Title { get; set; } |
This file contains 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
// Data/ApplicationDbContext.cs | |
public class ApplicationDbContext : IdentityDbContext | |
{ | |
...etc | |
public DbSet<Post> Posts { get; set; } | |
protected override void OnModelCreating(ModelBuilder builder) | |
{ |
This file contains 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
docker exec -it sql_server bash |
This file contains 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
/opt/mssql-tools/bin/sqlcmd -S localhost -U "sa" -P "yourPasswordHere" -I |
OlderNewer