using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics.Entity; using Microsoft.AspNet.Hosting; using Microsoft.Data.Entity; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; using <%= appName %>.Data; using <%= appName %>.Utils; namespace <%= appName %> { public class Startup { public static IConfiguration Configuration { get; set; } public Startup(IHostingEnvironment env) { Configuration = new Configuration() .AddJsonFile("config.json") .AddJsonFile($"config.{env.EnvironmentName}.json", true) .AddEnvironmentVariables(); } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure(Configuration.GetSubKey("AppSettings")); services.AddEntityFramework() .AddSqlServer() .AddDbContext<<%= appName %>Db>(options => options.UseSqlServer(Configuration["Data:<%= appName %>Db:ConnectionString"])); services.AddMvc(); } // Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) { loggerfactory.AddConsole(LogLevel.Information); if (env.IsDevelopment()) { app.UseErrorPage(ErrorPageOptions.ShowAll); app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll); } else { app.UseErrorHandler("/error"); } app.UseStaticFiles(); app.UseMvc(); } } }