Skip to content

Instantly share code, notes, and snippets.

@NileshGule
Last active January 10, 2018 15:33
Show Gist options
  • Save NileshGule/dba085620e01611e39589b6262164b79 to your computer and use it in GitHub Desktop.
Save NileshGule/dba085620e01611e39589b6262164b79 to your computer and use it in GitHub Desktop.
Gist related to 2nd part of SQL 2017 on Linux & Core MVC
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=sql2017;Initial Catalog=TechTalksDB;User Id=SA;Password=January2018;MultipleActiveResultSets=True"
},
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<!-- <TargetFramework>netcoreapp2.0</TargetFramework> -->
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.0-preview1-25919-02</RuntimeFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
version: '3'
services:
sql2017:
image: nileshgule/sqldb
hostname: 'sql2017'
container_name: sql2017
build:
context: ./Database
dockerfile: Dockerfile
ports:
- "1433:1433"
tty: true
coremvc:
image: nileshgule/coremvc
build:
context: ./CoreMVC
dockerfile: Dockerfile
depends_on:
- corewebapi
ports:
- "80:80"
corewebapi:
image: nileshgule/corewebapi
build:
context: ./CoreWebAPI
dockerfile: Dockerfile
depends_on:
- sql2017
ports:
- "8080:8080"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using CoreWebAPI.Models;
using Microsoft.EntityFrameworkCore;
namespace CoreWebAPI
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// services.AddDbContext<KeyValueContext>(o => o.UseInMemoryDatabase("KeyValueDB"));
services.AddDbContext<KeyValueContext>(
options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment