diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index e0bf0729a4..77aab79f54 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -26,9 +26,20 @@ namespace MusicStore app.UseServices(services => { + //If this type is present - we're on mono + var runningOnMono = Type.GetType("Mono.Runtime") != null; + // Add EF services to the services container - services.AddEntityFramework() - .AddSqlServer(); + if (runningOnMono) + { + services.AddEntityFramework() + .AddInMemoryStore(); + } + else + { + services.AddEntityFramework() + .AddSqlServer(); + } services.AddScoped(); @@ -37,7 +48,14 @@ namespace MusicStore { options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername"); options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword"); - options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString")); + if (runningOnMono) + { + options.UseInMemoryStore(); + } + else + { + options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString")); + } }); // Add Identity services to the services container diff --git a/src/MusicStore/project.json b/src/MusicStore/project.json index c75b2aa442..ba3e563f40 100644 --- a/src/MusicStore/project.json +++ b/src/MusicStore/project.json @@ -15,6 +15,8 @@ "Microsoft.AspNet.Security.Cookies": "1.0.0-*", "Microsoft.AspNet.StaticFiles": "1.0.0-*", "EntityFramework.SqlServer": "7.0.0-*", + /*For Mono*/ + "EntityFramework.InMemory": "7.0.0-*", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*", "Microsoft.Framework.OptionsModel": "1.0.0-*" },