Skip to content

Commit

Permalink
Merge pull request #1 from Pilchie/AddEf
Browse files Browse the repository at this point in the history
Try adding EF
  • Loading branch information
Pilchie committed Apr 30, 2016
2 parents f51f1fc + 9ca8cce commit df3d478
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 18 deletions.
5 changes: 4 additions & 1 deletion Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using HelloMvc.Data;
using Microsoft.AspNetCore.Mvc;
using Octokit;

Expand All @@ -8,10 +9,12 @@ namespace HelloMvc
public class HomeController : Controller
{
private readonly ApiConnection _apiConnection;
private readonly ApplicationDbContext _dbContext;

public HomeController(ApiConnection apiConnection)
public HomeController(ApiConnection apiConnection, ApplicationDbContext dbContext)
{
_apiConnection = apiConnection;
_dbContext = dbContext;
}

public async Task<IActionResult> Index()
Expand Down
27 changes: 27 additions & 0 deletions Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HelloMvc.Models;
using Microsoft.EntityFrameworkCore;

namespace HelloMvc.Data
{
public class ApplicationDbContext : DbContext
{
public DbSet<Issue> Issues { get; set; }

public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}

protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
}
12 changes: 12 additions & 0 deletions Models/Issue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace HelloMvc.Models
{
public class Issue
{
public int GitHubIssueNumber { get; set; }
public string Title { get; set; }
public string HtmlUrl { get; set; }
public string Milestone { get; set; }
public int? Priority { get; set; }
public int? StoryPoints { get; set; }
}
}
1 change: 1 addition & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="DotNetCore" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json"/>
<add key="AspNetCI" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
Expand Down
5 changes: 5 additions & 0 deletions Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using HelloMvc.Data;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -33,6 +35,9 @@ public Startup(IHostingEnvironment env)

public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));

services.AddMvc();

services.AddSingleton<ApiConnection, ApiConnection>(_ =>
Expand Down
17 changes: 10 additions & 7 deletions appsettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
"ConnectionStrings": {
"DefaultConnection": "Data Source=appdata.db"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
}
41 changes: 31 additions & 10 deletions project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,48 @@
"Microsoft.Extensions.Logging": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
"Microsoft.Extensions.Logging.Debug": "1.0.0-*",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-24008"
},
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-*",
"Octokit": "0.19.0",
"Microsoft.Net.Http": "2.2.29"
"Microsoft.Net.Http": "2.2.29",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-*",
"Microsoft.EntityFrameworkCore.Sqlite.Design": { "version": "1.0.0-*", "type": "build" },
"Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-*", "type": "build" }
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"netcore45",
"dotnet5.4"
]
"dnxcore50",
"portable-net452+win81"
],
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-24022"
}
}
}
},

"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*",
"dotnet-razor-tooling": "1.0.0-*"
"dotnet-aspnet-codegenerator": {
"version": "1.0.0-*",
"imports": [
"dnxcore50",
"portable-net452+win81"
]
},
"Microsoft.EntityFrameworkCore.Tools":{
"version": "1.0.0-*",
"imports": "portable-net452+win81"
},
"dotnet-razor-tooling": {
"version": "1.0.0-*",
"imports": [
"dnxcore50",
"portable-net452+win81"
]
}
},

"content": [
Expand Down

0 comments on commit df3d478

Please sign in to comment.