morry2341

Program.cs_bank

Nov 25th, 2022
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. using MyProject.DB;
  2. using Microsoft.EntityFrameworkCore;
  3. using MyProject.Services.Implementations;
  4. using MySql.Data.EntityFramework;
  5.  
  6. var builder = WebApplication.CreateBuilder(args);
  7.  
  8. // Add services to the container.
  9. builder.Services.AddAutoMapper(typeof(Program));
  10. builder.Services.AddControllers();
  11. builder.Services.AddMvc();
  12. var connection = @"server=localhost;port=3306;database=mydatabase;uid=root;pwd=mypwd";
  13. builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connection));
  14.  
  15. //builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
  16. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  17. builder.Services.AddEndpointsApiExplorer();
  18. builder.Services.AddSwaggerGen();
  19.  
  20. var app = builder.Build();
  21.  
  22. // Configure the HTTP request pipeline.
  23. if (app.Environment.IsDevelopment())
  24. {
  25. app.UseSwagger();
  26. app.UseSwaggerUI();
  27. }
  28.  
  29.  
  30. app.UseHttpsRedirection();
  31.  
  32. app.UseAuthorization();
  33.  
  34. app.MapControllers();
  35.  
  36. app.Run();
  37.  
Advertisement
Add Comment
Please, Sign In to add comment