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

Scaffolding with use-database-names and events table generates invalid code #31121

Closed
dshook opened this issue Jun 22, 2023 · 2 comments · Fixed by #32641
Closed

Scaffolding with use-database-names and events table generates invalid code #31121

dshook opened this issue Jun 22, 2023 · 2 comments · Fixed by #32641
Assignees
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug

Comments

@dshook
Copy link

dshook commented Jun 22, 2023

File a bug

I'm running this command
dotnet ef dbcontext scaffold --use-database-names --context-dir "Models" --output-dir "Models" -f "Name=ConnectionStrings:WebApiDatabase" Npgsql.EntityFrameworkCore.PostgreSQL
on a database that has an events table.

This generates an event.cs model file. However the event file is generated with invalid syntax because of the reserved keyword.

using System;
using System.Collections.Generic;

namespace reporting_api.Models;

public partial class event  // Identifier expected error here
{
    public int id { get; set; }

    public string type { get; set; } = null!;

    .....
}

This also happens with a files table.

Include provider and version information

EF Core version:
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL 7.0.4
Target framework: .NET 7.0
Operating system: OSX

@dshook
Copy link
Author

dshook commented Jun 22, 2023

The workaround I found is to use the --no-pluralize option, however it would be nice to have this automatically applied to only the conflicting names and not every table.

@ajcvickers
Copy link
Member

Note from triage: we should generate @events for this. This might be a regression from introduction of the T4 templates.

@ajcvickers ajcvickers added this to the Backlog milestone Jul 8, 2023
@ajcvickers ajcvickers self-assigned this Dec 19, 2023
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Dec 19, 2023
@ajcvickers ajcvickers modified the milestones: Backlog, 9.0.0 Dec 19, 2023
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview1 Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants