EFCore 10 RC1 - Issue with the generated parameter names
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
### Bug description
In EFCore 10, parameter names are getting simplified due to
https://github.com/dotnet/efcore/pull/35200
However this change could lead to generated parameter names which are reserved keyword for some database providers.
For Ex:- below LINQ
```C#
DateTime date = new DateTime(2024, 1, 1);
var listOfBlogs = context.Blogs.Where(i => i.DateOfPublish > date).ToList();
```
would generate below SQL with EFCore 10 RC1-
```
SELECT [b].[BlogId], [b].[DateOfPublish], [b].[Url]
FROM [Blogs] AS [b]
WHERE [b].[DateOfPublish] > @date
```
**date** is a reserved keyword for Oracle DB and running the LINQ would result in error.
In EFCore 9, the generated SQL is-
```
SELECT [b].[BlogId], [b].[DateOfPublish], [b].[Url]
FROM [Blogs] AS [b]
WHERE [b].[DateOfPublish] > @__date_0
```
which doesn't have any issue with the parameter name.
Is there any way for the database providers to keep using the old functionality of generating the parameters name?
Or is there a way that database providers can generate their own parameter names?
### Your code
```csharp
#
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public DateTime DateOfPublish { get; set; }
}
public class BloggingContext : DbContext
{
public DbSet Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"").LogTo(Console.WriteLine);
}
}
public class Program
{
public static void Main()
{
using (var context = new BloggingContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
if (!context.Blogs.Any())
{
context.Blogs.Add(new Blog { Url = "http://blogs.msdn.com/adonet", DateOfPublish = new DateTime(2025, 1, 1) });
context.Blogs.Add(new Blog { Url = "http://www.google.com", DateOfPublish = new DateTime(2024, 1, 1) });
context.Blogs.Add(new Blog { Url = "http://www.github.com", DateOfPublish = new DateTime(2023, 1, 1) });
context.SaveChanges();
}
DateTime date = new DateTime(2024, 1, 1);
var listOfBlogs = context.Blogs.Where(i => i.DateOfPublish > date).ToList();
}
}
}
```
### Stack traces
```text
```
### Verbose output
```text
```
### EF Core version
10.0 RC1
### Database provider
Microsoft.EntityFrameworkCore.SqlServer
### Target framework
.NET 10.0
### Operating system
Windows 11
### IDE
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.