Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/PhotoGallery/Infrastructure/PhotoGalleryContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public class PhotoGalleryContext : DbContext
public PhotoGalleryContext(DbContextOptions options) : base(options)
{
}

protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.UseInMemoryDatabase();
base.OnConfiguring(options);
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
Expand Down
26 changes: 13 additions & 13 deletions src/PhotoGallery/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.PlatformAbstractions;
using Microsoft.Extensions.Configuration;
using PhotoGallery.Infrastructure;
using Microsoft.Data.Entity;
using PhotoGallery.Infrastructure.Core;
using PhotoGallery.Infrastructure.Mappings;
using PhotoGallery.Infrastructure.Repositories;
using PhotoGallery.Infrastructure.Services;
using PhotoGallery.Infrastructure.Mappings;
using PhotoGallery.Infrastructure.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;

namespace PhotoGallery
{
public class Startup
{
private static string _applicationPath = string.Empty;

public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
_applicationPath = appEnv.ApplicationBasePath;
Expand All @@ -42,15 +43,15 @@ public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
}

public IConfigurationRoot Configuration { get; set; }

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
// Add Entity Framework services to the services container.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<PhotoGalleryContext>(options =>
options.UseSqlServer(Configuration["Data:PhotoGalleryConnection:ConnectionString"]));
.AddInMemoryDatabase()
.AddDbContext<PhotoGalleryContext>();

// Repositories
services.AddScoped<IPhotoRepository, PhotoRepository>();
Expand All @@ -74,7 +75,6 @@ public void ConfigureServices(IServiceCollection services)
{
policy.RequireClaim(ClaimTypes.Role, "Admin");
});

});

// Add MVC services to the services container.
Expand Down
2 changes: 1 addition & 1 deletion src/PhotoGallery/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Framework.DependencyInjection": "1.0.0-beta8",
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.InMemory": "7.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
Expand Down