Skip to content

anton-martyniuk/efcore-extensions-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EF Core Extensions Examples

Prerequisites

  • .NET 9.0 SDK
  • SQL Server (local, docker or remote instance)
  • IDE (Visual Studio, JetBrains Rider or Visual Studio Code) or .NET CLI

Getting Started

1. Configure Database Connection

Update the connection string in appsettings.json:

{
  "ConnectionStrings": {
    "SqlServer": "Server=YOUR_SERVER;Database=YOUR_DATABASE;User Id=YOUR_USER;Password=YOUR_PASSWORD;TrustServerCertificate=True;"
  }
}

Replace the following placeholders:

  • YOUR_SERVER - Your SQL Server instance address (e.g., localhost, 127.0.0.1,1433)
  • YOUR_DATABASE - Database name
  • YOUR_USER - SQL Server username
  • YOUR_PASSWORD - SQL Server password
  • Include TrustServerCertificate as needed

2. Run the Application

Option A: Using Visual Studio or Rider

  1. Open the solution in your IDE
  2. Press F5 or click the Run button
  3. The browser will automatically open with Swagger UI

Option B: Using .NET CLI

Navigate to the project directory and run:

dotnet run

3. Access the Application

The application will be available at:

When running from Visual Studio or Rider, the browser will automatically open to the Swagger page.

4. Verify the Application is Running

Check the console logs for messages indicating a successful startup:

5. Test the Endpoints

Using Swagger UI

  1. Navigate to the Swagger page (automatically opened or manually visit the URLs above)
  2. Expand the available endpoints
  3. Click "Try it out" on any endpoint
  4. Fill in the required parameters
  5. Click "Execute" to test the endpoint

Using Postman

  1. Import or manually create requests for the available endpoints
  2. Set the base URL to http://localhost:5001 or https://localhost:5000
  3. Send requests and verify responses

Troubleshooting

  • If the application fails to start, check the console logs for error messages
  • Verify your SQL Server instance is running and accessible
  • Ensure the connection string is correctly configured
  • Check that port 5000 (HTTPS) and 5001 (HTTP) are not being used by other applications

Running Benchmarks

This repo includes a BenchmarkDotNet project that measures EF Core vs bulk operations.

  • Project path: ReturningIdentityValue/Benchmarks
  • Framework: net9.0

1. Configure the database connection

Update the connection string in ReturningIdentityValue/Benchmarks/appsettings.json (and optionally appsettings.Development.json) to point to your SQL Server:

{
  "ConnectionStrings": {
    "SqlServer": "Server=YOUR_SERVER;Database=YOUR_DATABASE;User Id=YOUR_USER;Password=YOUR_PASSWORD;TrustServerCertificate=True;"
  }
}

Make sure the target database is reachable and the user has permissions to create tables and insert data.

2. Build (Release)

From the repository root:

dotnet build -c Release

3. Run the benchmarks (Release)

From the repository root, run the Benchmarks project in Release configuration:

# Run all benchmarks
dotnet run -c Release --project ReturningIdentityValue/Benchmarks

BenchmarkDotNet places results under ReturningIdentityValue/Benchmarks/BenchmarkDotNet.Artifacts/results as .md and .html reports.

Tips for stable results

  • Close other heavy applications; keep the machine idle during runs.
  • Prefer running on AC power and a performance power plan.
  • Use the same SQL Server instance for all runs; ensure it's not under external load.
  • Results are comparative; look at ratios between baselines and alternatives.

About

EF Core Extensions project examples

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages