รายการ 100 ไลบรารี (Libraries/Packages) ที่เกี่ยวข้องกับ ASP.NET Core Web API

By suparat · 08 Oct 2025


แน่นอน! 😎 ผมจะทำเป็น รายการ 100 ไลบรารี (Libraries/Packages) ที่เกี่ยวข้องกับ ASP.NET Core Web API พร้อมคำอธิบายและตัวอย่างโค้ดสั้น ๆ เพื่อให้เห็นการใช้งานจริง คุณสามารถใช้เป็น reference ในโปรเจกต์ได้


1–20: Core & Utilities

  1. Microsoft.AspNetCore.App

    • คำอธิบาย: Framework หลักสำหรับ ASP.NET Core (Web API, MVC, Razor Pages)

    • ตัวอย่าง: ใช้ app.UseRouting() และ app.UseEndpoints()

  2. Microsoft.EntityFrameworkCore

    • คำอธิบาย: ORM สำหรับทำงานกับ Database

    • ตัวอย่าง:

      services.AddDbContext<AppDbContext>(options =>
          options.UseSqlServer(connectionString));
      
  3. Microsoft.EntityFrameworkCore.SqlServer

    • คำอธิบาย: SQL Server provider สำหรับ EF Core

    • ตัวอย่าง: options.UseSqlServer("YourConnectionString")

  4. Microsoft.EntityFrameworkCore.InMemory

    • คำอธิบาย: In-memory database สำหรับ Unit Test

    • ตัวอย่าง:

      options.UseInMemoryDatabase("TestDb");
      
  5. Microsoft.AspNetCore.Authentication.JwtBearer

    • คำอธิบาย: ใช้ JWT authentication

    • ตัวอย่าง:

      services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
              .AddJwtBearer(options => { /* config */ });
      
  6. Microsoft.AspNetCore.Mvc.NewtonsoftJson

    • คำอธิบาย: ใช้ Json.NET แทน System.Text.Json

    • ตัวอย่าง:

      services.AddControllers().AddNewtonsoftJson();
      
  7. Microsoft.AspNetCore.Identity

    • คำอธิบาย: ระบบจัดการผู้ใช้และสิทธิ์

    • ตัวอย่าง:

      services.AddIdentity<ApplicationUser, IdentityRole>()
              .AddEntityFrameworkStores<AppDbContext>();
      
  8. AutoMapper.Extensions.Microsoft.DependencyInjection

    • คำอธิบาย: Mapping ระหว่าง DTO กับ Entity

    • ตัวอย่าง:

      services.AddAutoMapper(typeof(Startup));
      
  9. FluentValidation.AspNetCore

    • คำอธิบาย: Validation rules แบบ declarative

    • ตัวอย่าง:

      services.AddControllers().AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<Startup>());
      
  10. Swashbuckle.AspNetCore

    • คำอธิบาย: สร้าง Swagger/OpenAPI สำหรับ Web API

    • ตัวอย่าง:

      services.AddSwaggerGen();
      app.UseSwagger();
      app.UseSwaggerUI();
      
  11. Serilog.AspNetCore

    • คำอธิบาย: Logging framework

    • ตัวอย่าง:

      Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
      
  12. NLog.Web.AspNetCore

    • คำอธิบาย: Logging อีกตัวที่นิยม

    • ตัวอย่าง: NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();

  13. Polly

    • คำอธิบาย: Retry, Circuit breaker, Timeout policies สำหรับ HttpClient

    • ตัวอย่าง:

      services.AddHttpClient("MyClient").AddTransientHttpErrorPolicy(p => p.RetryAsync(3));
      
  14. MediatR.Extensions.Microsoft.DependencyInjection

    • คำอธิบาย: CQRS/Mediator pattern

    • ตัวอย่าง:

      services.AddMediatR(typeof(Startup));
      
  15. Hangfire

    • คำอธิบาย: Background Job processing

    • ตัวอย่าง:

      app.UseHangfireDashboard();
      BackgroundJob.Enqueue(() => Console.WriteLine("Hello Hangfire"));
      
  16. Newtonsoft.Json

    • คำอธิบาย: Serialize/Deserialize JSON

    • ตัวอย่าง:

      var json = JsonConvert.SerializeObject(obj);
      
  17. Dapper

    • คำอธิบาย: Micro ORM, ใช้ง่ายกว่า EF

    • ตัวอย่าง:

      var user = connection.QueryFirst<User>("SELECT * FROM Users WHERE Id = @Id", new { Id = 1 });
      
  18. FluentAssertions

    • คำอธิบาย: Unit Test assertions แบบ readable

    • ตัวอย่าง:

      result.Should().NotBeNull();
      
  19. Bogus

    • คำอธิบาย: สร้าง fake data สำหรับ testing

    • ตัวอย่าง:

      var faker = new Faker<User>().RuleFor(u => u.Name, f => f.Name.FullName());
      
  20. Mapster

    • คำอธิบาย: Alternative ของ AutoMapper

    • ตัวอย่าง: destination = source.Adapt<Destination>();


21–40: Database & ORM

  1. Microsoft.EntityFrameworkCore.Sqlite – SQLite provider

  2. Microsoft.EntityFrameworkCore.Design – สำหรับ migrations

  3. Microsoft.EntityFrameworkCore.Tools – CLI tools EF Core

  4. EFCore.BulkExtensions – Bulk insert/update/delete

  5. Npgsql.EntityFrameworkCore.PostgreSQL – PostgreSQL provider

  6. Pomelo.EntityFrameworkCore.MySql – MySQL provider

  7. Microsoft.Data.SqlClient – SQL Server client

  8. MongoDB.Driver – MongoDB client

  9. Redis.OM – Redis object mapping

  10. StackExchange.Redis – Redis cache

  11. LiteDB – Embedded NoSQL database

  12. EFCoreSecondLevelCacheInterceptor – Second-level caching EF Core

  13. Audit.EntityFramework.Core – Audit logs for EF Core

  14. EntityFramework.Exceptions.SqlServer – Exception handling EF Core

  15. GraphQL.Server.Transports.AspNetCore – GraphQL integration

  16. HotChocolate.AspNetCore – GraphQL server

  17. Dapper.Contrib – Extension methods Dapper

  18. Marten – PostgreSQL-based document DB

  19. ServiceStack.OrmLite – Lightweight ORM

  20. RepoDb – Hybrid ORM for .NET


41–60: Authentication & Authorization

  1. IdentityServer4 – OpenID Connect / OAuth2

  2. OpenIddict – Alternative OAuth2 server

  3. AspNet.Security.OAuth.Validation – Token validation

  4. AspNet.Security.OAuth.Providers – Social login providers

  5. Jwt.Net – JWT library

  6. Microsoft.AspNetCore.Authorization – Policy-based auth

  7. AspNetCoreRateLimit – Rate limiting middleware

  8. Duende.IdentityServer – Commercial IdentityServer

  9. Microsoft.AspNetCore.DataProtection – Encryption / secure storage

  10. AspNetCore.Authentication.Google – Google login

  11. AspNetCore.Authentication.Facebook – Facebook login

  12. AspNetCore.Authentication.MicrosoftAccount – Microsoft login

  13. AspNetCore.Authentication.Twitter – Twitter login

  14. AspNetCore.Authentication.Cookies – Cookie auth

  15. AspNetCore.Authentication.OAuth – Generic OAuth

  16. AspNetCore.Authentication.OpenIdConnect – OpenID auth

  17. Microsoft.AspNetCore.HttpOverrides – Proxy headers

  18. Microsoft.AspNetCore.Cors – CORS policy

  19. AspNetCoreRateLimit – API throttling

  20. FluffySpoon.AspNet.LetsEncrypt – Auto HTTPS certs


61–80: Caching & Performance

  1. CacheManager.Core – Multi-layer caching

  2. Microsoft.Extensions.Caching.Memory – In-memory cache

  3. Microsoft.Extensions.Caching.Redis – Redis cache

  4. LazyCache – Simple caching library

  5. EFCoreSecondLevelCacheInterceptor – EF caching

  6. EasyCaching – Multiple cache providers

  7. AspNetCore.ResponseCaching – HTTP response cache

  8. StackExchange.Redis.Extensions – Redis helper

  9. CacheCow.Server – HTTP caching

  10. MemoryCache.Monitor – Monitor cache usage

  11. MiniProfiler.AspNetCore.Mvc – Performance profiling

  12. App.Metrics.AspNetCore – Metrics collection

  13. Prometheus.AspNetCore – Prometheus metrics

  14. Hangfire.MemoryStorage – In-memory background jobs

  15. Quartz – Scheduler / cron jobs

  16. Coravel – Background tasks / scheduling

  17. MediatR.Extensions.Autofac.DependencyInjection – DI integration

  18. Autofac.Extensions.DependencyInjection – DI container

  19. SimpleInjector.Integration.AspNetCore.Mvc – DI container

  20. Scrutor – Assembly scanning & DI registration


81–100: Miscellaneous & Dev Tools

  1. Serilog.Sinks.File – File logging

  2. Serilog.Sinks.Console – Console logging

  3. Serilog.Sinks.Seq – Logging to Seq

  4. Serilog.Sinks.MSSqlServer – Logging to SQL

  5. Seq.Client – Logging client

  6. Refit – Type-safe REST API client

  7. RestSharp – HTTP client

  8. Flurl.Http – HTTP client fluent syntax

  9. Polly.Extensions.Http – Retry for HttpClient

  10. DotNet.Testcontainers – Docker integration for tests

  11. WireMock.Net – Mock API server

  12. Moq – Mocking in Unit Tests

  13. NSubstitute – Alternative mocking

  14. xUnit – Unit testing framework

  15. NUnit – Unit testing framework

  16. Microsoft.AspNetCore.TestHost – In-memory testing

  17. Playwright – End-to-end testing

  18. Selenium.WebDriver – Browser automation

  19. Swashbuckle.AspNetCore.Annotations – Swagger annotations

  20. NSwag.AspNetCore – Swagger/OpenAPI generator


💡 เคล็ดลับ:

  • ไลบรารีหลายตัวสามารถใช้ร่วมกันได้ เช่น AutoMapper + FluentValidation + MediatR สำหรับ CQRS pattern

  • ควรเลือกใช้อย่างเหมาะสมกับขนาดโปรเจกต์: โปรเจกต์เล็กไม่จำเป็นต้องใช้ทั้งหมด

 

รายการ 100 ไลบรารี (Libraries/Packages) ที่เกี่ยวข้องกับ ASP.NET Core Web API
Web hosting by Somee.com