Download presentation
Presentation is loading. Please wait.
1
Platform Independent Full Stack Development
New Frontiers Platform Independent Full Stack Development
2
Thanks to our GOLD Sponsor
3
Thanks to our SILVER Sponsors
4
What’s On Deck? Quick Introduction to Our Toolset
Creating the Database Server Defining Our Database Shape Creating the Service Layer Testing It! VS Code vs. Visual Studio Community/Professional/Enterprise Azure Data Studio vs. SQL Server Management Studio Question Time
5
Our Toolset for Today 1. iTerm2 2. Docker w/ SQL Server 2017 Linux
2. Docker w/ SQL Server 2017 Linux 3. SQL Ops Studio Azure Data Studio 4. dotnet Command Line 5. Visual Studio Code 6. Postman
6
Creating the Database Server
7
Create a New Docker Volume
docker volume create --name sql_saturday_madison
8
Create a SQL Server Instance
sudo docker pull microsoft/mssql-server-linux:2017-latest docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=password123!' -p 1433:1433 -v sql_saturday_madison:/var/opt/mssql --name sql_saturday_madison -d microsoft/mssql-server-linux:2017-latest
9
Azure Data Studio
10
Creating the Database Shape
11
Create User and Database
CREATE LOGIN [Sql_Saturday_User] WITH PASSWORD = 'password123!'; GO CREATE DATABASE [Sql_Saturday]; USE [Sql_Saturday]; CREATE USER [Sql_Saturday_User] FOR LOGIN [Sql_Saturday_User]; EXEC sp_addrolemember 'db_owner’, Sql_Saturday_User';
12
Create the Song Table CREATE TABLE dbo.Song ( SongId UNIQUEIDENTIFIER NOT NULL CONSTRAINT PK_Song PRIMARY KEY CLUSTERED, SongName VARCHAR(150) NOT NULL, Composer VARCHAR(150) NOT NULL ) ON [PRIMARY]; GO
13
Fill It INSERT INTO dbo.Song (SongId, SongName, Composer) SELECT NEWID(), 'Two Step', 'Dave Matthews Band' UNION SELECT NEWID(), 'Crush', 'Dave Matthews Band' SELECT NEWID(), 'One Sweet World', 'Dave Matthews Band' SELECT NEWID(), 'All Along the Watchtower', 'Bob Dylan' SELECT NEWID(), 'Minarets', 'Dave Matthews Band' SELECT NEWID(), 'Why I Am', 'Dave Matthews Band' SELECT NEWID(), 'Warehouse', 'Dave Matthews Band' SELECT NEWID(), 'Grey Street', 'Dave Matthews Band'; GO
14
Create the Concert Table
CREATE TABLE dbo.Concert ( ConcertId UNIQUEIDENTIFIER NOT NULL CONSTRAINT PK_Concert PRIMARY KEY CLUSTERED, ConcertDate DATE NOT NULL, ConcertLocation VARCHAR(150) NOT NULL ) ON [PRIMARY]; GO
15
Fill It INSERT INTO dbo.Concert (ConcertId, ConcertLocation, ConcertDate) SELECT NEWID(), 'Keybank Pavilion, Burgettstown, PA', ' ' UNION SELECT NEWID(), 'Alpine Valley Music Center, Elkhorn, WI', ' ' SELECT NEWID(), 'Alpine Valley Music Center, Elkhorn, WI', ' ' SELECT NEWID(), 'Riverbend Music Center, Cincinnati, OH', ' '; GO
16
dotnet Command Line
17
Create a New WebAPI Project
cd ./code mkdir new-frontiers cd ./new-frontiers dotnet new webapi --name NewFrontiers -o ./new-frontiers code .
18
Visual Studio Code
19
Coding in VS Code
20
Install Entity Framework Core
dotnet add package Microsoft.EntityFrameworkCore.SqlServer dotnet add package Microsoft.CodeAnalysis
21
Update Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var connectionString services.AddDbContext<ConcertDbContext>(options => options.UseSqlServer(connectionString)); }
22
Add a Song Model public class Song { public Guid SongId {get;set;} public string SongName {get;set;} public string Composer {get;set;} }
23
Add a Concert Model public class Concert { public Guid ConcertId {get;set;} public string ConcertLocation {get;set;} public DateTime ConcertDate {get;set;} }
24
Create Out DbContext public class ConcertDbContext : DbContext { public ConcertDbContext(DbContextOptions<ConcertDbContext> options) :base (options) } public DbSet<Song> Songs {get;set;} public DbSet<Concert> Concerts {get;set;} protected override void OnModelCreating(ModelBuilder builder) builder.Entity<Song>(s => { s.ToTable("Song", "dbo"); s.HasKey(c => c.SongId); s.Property(sid => sid.SongId).ValueGeneratedOnAdd(); s.Property(c => c.Composer).IsRequired().HasMaxLength(150); s.Property(sn => sn.SongName).IsRequired().HasMaxLength(150); }); builder.Entity<Concert>(c => { c.ToTable("Concert", "dbo"); c.HasKey(cid => cid.ConcertId); c.Property(cid => cid.ConcertId).ValueGeneratedOnAdd(); c.Property(cl => cl.ConcertLocation).IsRequired().HasMaxLength(150); c.Property(cd => cd.ConcertDate).IsRequired().HasColumnType("date");
25
Add a Song Controller [Route("api/[controller]")] [ApiController] public class SongController : Controller { private ConcertDbContext _context; public SongController(ConcertDbContext context) this._context = context; } [HttpGet("")] public async Task<ActionResult<IEnumerable<Song>>> GetAllSongs() var data = await this._context.Songs.ToListAsync(); return Ok(data); [HttpPost("")] public async Task<ActionResult<Song>> CreateSong(Song song) var result = await this._context.AddAsync(song); await this._context.SaveChangesAsync(); return song;
26
Add a Concert Controller
[Route("api/[controller]")] [ApiController] public class ConcertController : Controller { private ConcertDbContext _context; public ConcertController(ConcertDbContext context) this._context = context; } [HttpGet("")] public async Task<ActionResult<IEnumerable<Concert>>> GetAllConcert() var data = await this._context.Concerts.ToListAsync(); return Ok(data); [HttpPost("")] public async Task<ActionResult<Concert>> CreateConcert(Concert concert) var result = await this._context.AddAsync(concert); await this._context.SaveChangesAsync(); return concert;
27
Test It Out dotnet run
28
Tool Comparisons
29
Visual Studio Code vs. Visual Studio
Cross-platform – versions available for Windows, Mac, and several flavors of Linux Rich Plugin Environment Lightweight Installation and Run Requirements Limited Scaffolding Support Within IDE No Integrated Test Runner (dotnet test only) Visual Studio Windows-only (Visual Studio for Mac does not provide a full experience) Rich Plugin Environment Heavyweight Installation and Run Requirements Full Scaffolding Support Within IDE Full Integrated Test Runner
30
Azure Data Studio vs. SQL Server Management Studio
Recently Out of Beta Cross Platform – versions available for Windows, Mac, and several flavors of Linux Limited Plugin Environment, but Install from Within the IDE Still May Encounter Areas of Limited Functionality Designed to be Cloud-first SQL Server Management Studio On Version 17 (Version 18 is currently in RC1) Windows-only Limited Plugin Environment (and most are 3rd Party Installations) Fully Functional Designed to be On-premise-first
31
Questions?
32
Who am I? Dan Mallott Twitter: @DanielMallott
Github: LinkedIn: Principal for West Monroe Partners In the industry since 2011 Primary experience with SQL Server, starting with SQL Server 2005 Also worked with Oracle, PostgreSQL, and Cassandra Been both a DBA and a developer Have a couple Microsoft certifications DataStax Certified Professional
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.