Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will EF Core 8 Work with SQL Server 2022 Compatibility Level 110? #35630

Open
princegearydymosco opened this issue Feb 12, 2025 · 3 comments
Open

Comments

@princegearydymosco
Copy link

Question

Hello,

I have a server running SQL Server 2022, but the database has a compatibility level 110 due to my legacy system. I am developing a new system and planning to upgrade to EF Core 8 with .NET 8.0.

Currently, I am fetching data from the database using this configuration:

options.UseSqlServer("<connection_string>", o => o.UseCompatibilityLevel(120));

It seems to be working so far, but I am concerned if this is a safe approach. Specifically:

  • The SQL Server instance is running 2022, but with compatibility level 110 (SQL Server 2012).
  • Will this work reliably with EF Core 8?
  • Is it risky to set the compatibility level to 120 while the database is still on compatibility level 110?
  • I cannot make changes to the legacy system or its database.

I would appreciate your insights into whether this approach could lead to issues or if there's anything I need to watch out for.

Thanks!

Your code

`options.UseSqlServer("<connection_string>", o => o.UseCompatibilityLevel(120));
`

Stack traces


Verbose output


EF Core version

8.0.0

Database provider

No response

Target framework

.NET 8.0

Operating system

No response

IDE

No response

@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 12, 2025

Will this work reliably with EF Core 8? - yes

Is it risky to set the compatibility level to 120 while the database is still on compatibility level 110? - No

This is unlikely to change for future EF Core versions

@roji
Copy link
Member

roji commented Feb 12, 2025

Is it risky to set the compatibility level to 120 while the database is still on compatibility level 110? - No

Why would you set the compatibility level to something that's higher than what your database is actually configured to support? Here I'll actually disagree with @ErikEJ - the whole point of EF's compatibility level setting is to tell EF that it can generate SQL that will only work starting with that compatibility level. So I'm not sure if there's specifically something EF generates that works on 120 but not on 110, but there could be. Why not simply set the compatibility level to the right value?

@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 12, 2025

Sorry, I assumed 110 was not allowed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants