Startup.cs 965 B

123456789101112131415161718192021222324252627282930313233
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using Microsoft.EntityFrameworkCore;
  4. using WebApplication1.Models;
  5. namespace WebApplication1
  6. {
  7. public class Startup
  8. {
  9. public void ConfigureServices(IServiceCollection services)
  10. {
  11. string con = "Server=(localdb)\\mssqllocaldb;Database=usersdbstore;Trusted_Connection=True;";
  12. // óñòàíàâëèâàåì êîíòåêñò äàííûõ
  13. services.AddDbContext<UsersContext>(options => options.UseSqlServer(con));
  14. services.AddControllers(); // èñïîëüçóåì êîíòðîëëåðû áåç ïðåäñòàâëåíèé
  15. }
  16. public void Configure(IApplicationBuilder app)
  17. {
  18. app.UseDeveloperExceptionPage();
  19. app.UseDefaultFiles();
  20. app.UseStaticFiles();
  21. app.UseRouting();
  22. app.UseEndpoints(endpoints =>
  23. {
  24. endpoints.MapControllers();
  25. });
  26. }
  27. }
  28. }