GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - 4dwaffle/EfNextValue

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
EfNextValue.Tests
EfNextValue.Tests
 
 
.gitignore
.gitignore
 
 
EfNextValue.slnx
EfNextValue.slnx
 
 
NuGet.Config
NuGet.Config
 
 
README.md
README.md
 
 

Repository files navigation

EF Core manual SQL Server sequence value

Test

Minimal integration test showing how to obtain a SQL Server sequence value with EF Core 10 before inserting an entity. The test starts a real SQL Server 2025 container with Testcontainers, creates the sequence, reads its next value, inserts the entity, and verifies the stored row.

The working query deliberately materializes before calling Single():

var values = await db.Database
    .SqlQuery<long>($"SELECT NEXT VALUE FOR [Schema].[Custom Value]")
    .ToListAsync();
var nextValue = values.Single();

Calling SingleAsync() directly is not valid for this SQL. EF Core composes it as a derived table, but SQL Server does not allow NEXT VALUE FOR in a derived table. ToListAsync() executes the raw SQL without that composition; Single() then checks the cardinality in memory.

Prerequisites:

  • .NET 10 SDK
  • Docker

Run the example:

dotnet test EfNextValue.slnx

About

No description, website, or topics provided.

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.