Advertisement
Guest User

startup.cs asp.net core.2.0

a guest
Oct 30th, 2017
539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.Extensions.Configuration;
  8. using Microsoft.Extensions.DependencyInjection;
  9. using Microsoft.EntityFrameworkCore;
  10. using Microsoft.EntityFrameworkCore.Extensions;
  11. using MySql.Data.EntityFrameworkCore.Extensions;
  12. using LearnEFCore.Data;
  13.  
  14.  
  15. namespace LearnEFCore
  16. {
  17.     public class Startup
  18.     {
  19.         public Startup(IConfiguration configuration)
  20.         {
  21.             Configuration = configuration;
  22.         }
  23.  
  24.         public IConfiguration Configuration { get; }
  25.  
  26.         // This method gets called by the runtime. Use this method to add services to the container.
  27.         public void ConfigureServices(IServiceCollection services)
  28.         {
  29.             var sqlConnectionString = Configuration.GetConnectionString("DataAccessMySqlProvider");
  30.             services.AddDbContext<SchoolContext>(options => options.UseMySql(sqlConnectionString));
  31.             services.AddMvc();
  32.         }
  33.  
  34.         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  35.         public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  36.         {
  37.             if (env.IsDevelopment())
  38.             {
  39.                 app.UseDeveloperExceptionPage();
  40.                 app.UseBrowserLink();
  41.             }
  42.             else
  43.             {
  44.                 app.UseExceptionHandler("/Home/Error");
  45.             }
  46.  
  47.             app.UseStaticFiles();
  48.  
  49.             app.UseMvc(routes =>
  50.             {
  51.                 routes.MapRoute(
  52.                     name: "default",
  53.                     template: "{controller=Home}/{action=Index}/{id?}");
  54.             });
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement