diff --git a/src/PhotoGallery/Infrastructure/PhotoGalleryContext.cs b/src/PhotoGallery/Infrastructure/PhotoGalleryContext.cs index 9b12339..328b429 100644 --- a/src/PhotoGallery/Infrastructure/PhotoGalleryContext.cs +++ b/src/PhotoGallery/Infrastructure/PhotoGalleryContext.cs @@ -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) { diff --git a/src/PhotoGallery/Startup.cs b/src/PhotoGallery/Startup.cs index 54455ee..11cd9ff 100644 --- a/src/PhotoGallery/Startup.cs +++ b/src/PhotoGallery/Startup.cs @@ -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; @@ -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(options => - options.UseSqlServer(Configuration["Data:PhotoGalleryConnection:ConnectionString"])); + .AddInMemoryDatabase() + .AddDbContext(); // Repositories services.AddScoped(); @@ -74,7 +75,6 @@ public void ConfigureServices(IServiceCollection services) { policy.RequireClaim(ClaimTypes.Role, "Admin"); }); - }); // Add MVC services to the services container. diff --git a/src/PhotoGallery/project.json b/src/PhotoGallery/project.json index 5f5f290..b6f363d 100644 --- a/src/PhotoGallery/project.json +++ b/src/PhotoGallery/project.json @@ -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",