Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Use of newer functions, although explicitly older version 3.1 chosen, navigation properties #266

Closed
FSharpCSharp opened this issue Feb 2, 2021 · 4 comments
Labels
bug Confirmed bug released Issue is resolved in a current release
Milestone

Comments

@FSharpCSharp
Copy link

I have created a model here, which refers to the 3.X version of the Entity Framework.

image

However, the generated code contains functions available only in higher versions, despite the choice of the 3.X version.

image

'EntityTypeBuilder<Xyz>' does not contain a definition for 'Navigation' and no accessible extension method 'Navigation' accepting a first argument of type 'EntityTypeBuilder<Xyz>' could be found (are you missing a using directive or an assembly reference?)

Here in the Entity Framework Core source code you can see that quite well. The "Navigation" function exists only in the newer versions, in version 3.X it was not present at this point.

Current version:
https://github.com/dotnet/efcore/blob/f54b9dcd189c91fc4b01b79c9387d23095819a8f/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs#L230

Old version 3.1:
https://github.com/dotnet/efcore/blob/release/3.1/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs

For this reason a compilation is not possible. The following packages are present in the .NET Framework 4.8 project:

    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Design" Version="1.1.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>

Did I maybe forget something, or overlooked something? Unfortunately, so far I can't get the model for the old version 3.1 to work at all. This is really a pity.

@msawczyn msawczyn added the investigating Looking into this label Feb 4, 2021
@msawczyn msawczyn added bug Confirmed bug and removed investigating Looking into this labels Feb 11, 2021
@msawczyn msawczyn added this to the 3.0.4 milestone Feb 11, 2021
msawczyn added a commit that referenced this issue Feb 11, 2021
   - Fix to detecting correct EF version with anything with "Latest" in it is configured (see #266)
   - Fix to generate correct initial value code for decimal properties (see #268)
   - Fix for constructor code generation in 1-N unidirectional associations (see #263)
@msawczyn
Copy link
Owner

Progress update on this. It's been tracked down to the designer incorrectly tying the chosen EF version to capabilities (therefore, to code generation type). The fix is underway and is currently in the testing stage.

@msawczyn
Copy link
Owner

Could you give 3.0.4 RC1 (available at https://github.com/msawczyn/EFDesigner/blob/master/dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix) a try? I believe this problem is now resolved.

@FSharpCSharp
Copy link
Author

That sounds excellent! Unfortunately, I won't be able to test it today, but I will definitely do so next week. I would then give a short feedback if everything is working properly now! Have a nice weekend, and thanks for the quick analysis / possible fix of the problem!

@msawczyn msawczyn added the pending release Issue is resolved in the current codebase, will be published with the next release label Feb 13, 2021
@FSharpCSharp
Copy link
Author

Good news! Looks like the bug is indeed fixed. Thanks a lot for that.

@msawczyn msawczyn added released Issue is resolved in a current release and removed pending release Issue is resolved in the current codebase, will be published with the next release labels Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Confirmed bug released Issue is resolved in a current release
Projects
None yet
Development

No branches or pull requests

2 participants