You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered:
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 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.
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:
it needs to be this, for it to be correct and compile:
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.
The text was updated successfully, but these errors were encountered: