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

Fully qualified attributes #27196

Closed
HakanL opened this issue Jan 16, 2022 · 3 comments
Closed

Fully qualified attributes #27196

HakanL opened this issue Jan 16, 2022 · 3 comments

Comments

@HakanL
Copy link

HakanL commented Jan 16, 2022

I'm using the Scaffold-DbContext command to reverse-engineer an existing database. I have used this since EF Core 3. In EF Core 6 I'm starting to have a problem with this line:

[InverseProperty(nameof(User.Role))]

it needs to be this, for it to be correct and compile:

[InverseProperty(nameof(DataModel.Models.User.Role))]

Otherwise I'm getting this error:
error CS0120: An object reference is required for the non-static field, method, or property 'Role.User'

My question is, is there an option to fully-qualify these attributes, or is there a better way to resolve this issue? I can't change the database structure, and I need to be able to re-generate the scaffolding whenever the database is changed, hopefully without manually changing this file every time.

@HakanL
Copy link
Author

HakanL commented Jan 16, 2022

I have a similar, but different issue when using Optimize-DbContext. I have a database table (again that I can't change) that's called DayOfWeek. When the compiled models are generated they aren't using fully qualified class names, so I'm getting an error when compiling saying:
error CS0104: 'DayOfWeek' is an ambiguous reference between 'MyCode.DataModel.Models.DayOfWeek' and 'System.DayOfWeek'
I've manually added this line to solve it, but it would be good to have an option that the generated code would always use fully qualified references:
using DayOfWeek = MyCode.DataModel.Models.DayOfWeek;

@ajcvickers
Copy link
Member

@HakanL The first issue is covered by #26588. The second one is a duplicate of #25523.

@HakanL
Copy link
Author

HakanL commented Jan 17, 2022

@ajcvickers Thank you for pointing me to those, I did some searches and couldn't find anything, but I now realize I think I only searched open issues, assuming this wasn't resolved. Unfortunately none of those issues have any fixes that I can use for 6.0 but I'll close this question as it's been answered.

@HakanL HakanL closed this as completed Jan 17, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
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

2 participants