ErikEJ / EntityFramework6PowerTools

This is the codebase for Entity Framework 6 Power Tools Community Edition, and modern EF 6 providers for SQL Server and SQL Server Compact
Other
183 stars 27 forks source link

Test MDS edmx with VS 17.5 #118

Closed ErikEJ closed 1 year ago

ErikEJ commented 1 year ago

See https://github.com/ErikEJ/EntityFramework6PowerTools/pull/119

See https://github.com/dotnet/ef6tools/pull/41 for a fix in progress

@ajcvickers FYI

robertmclaws commented 1 year ago

So, I've pulled down this project and tried opening the Model1.edms file in SmokeTestNetFx on both my main system, and TWO separate clean systems I spun up on Windows 11.

On all 3 systems, when I change SmokeTestNetCore to the following, I get a NullReferenceException when trying to open the designer.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net48;net6.0</TargetFrameworks>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="..\SqlProviderSmokeTextNetCore\Test1.cs" Link="Test1.cs" />
  </ItemGroup>

  <ItemGroup>
    <None Include="..\SmokeTestNetFx\Model1.edmx" Link="Model1.edmx" />
    <None Include="..\SmokeTestNetFx\Model1.edmx.diagram" Link="Model1.edmx.diagram" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="ErikEJ.EntityFramework.SqlServer" Version="6.6.3" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
    <PackageReference Include="xunit" Version="2.4.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
    <PackageReference Include="coverlet.collector" Version="1.2.0" />
  </ItemGroup>

</Project>

I'm using the same project configuration in my own app, with the same result.

ErikEJ commented 1 year ago

@robertmclaws The designer only works on pure .NET Framework projects. Are you not able to open The designer in the unmodified NetFX smoke test project?

robertmclaws commented 1 year ago

So, EF6 works under both .NET Framework and .NET Core. The designer used to work just fine in this configuration under VS2022 when the provider was System.Data.SqlClient.

NOW it doesn't even work in that situation, and model updates are totally broken.

The designer needs to work on any platform that EF6 works on.

ErikEJ commented 1 year ago

 Are you not able to open The designer in the unmodified NetFX smoke test project?

Please reply. As far as I know the designer never worked with s ting else than classic .NET Framework projects

robertmclaws commented 1 year ago

No. It is still giving a Null Reference Exception on all 3 systems.

ErikEJ commented 1 year ago

On another PC also? Which VS version?

Share you 64 bit machine.config system.data section.

robertmclaws commented 1 year ago

Windows 11 x64, VS2022 17.5.1 x64. This is all that's in there, on all 3 machines:

    <system.data>
        <DbProviderFactories />
    </system.data>

Not sure if it is supposed to be different, or of Windows Update is overwriting it, or what.

robertmclaws commented 1 year ago

Are you not able to open The designer in the unmodified NetFX smoke test project?

Please reply. As far as I know the designer never worked with s ting else than classic .NET Framework projects

Also, if you look at the project file I posted, it used to work if you listed .NET 4.8 FIRST in the list of projects to compile. I've been using it that way for the last 3+ years.

ErikEJ commented 1 year ago

@robertmclaws can you share a repro project, I am confused with talk about new project types and multiple target frameworks.

The designer only works with classic. Net framework projects.

robertmclaws commented 1 year ago

You've said a couple times now "the designer only works with classic .NET Framework projects." As I have mentioned a few times now, that statement is not accurate. The designer works in SDK-style projects as well, but the .NET Framework (net462, net47, net471, net472, or net48) HAS to be specified as the first entry in <TargetFrameworks />

I know this because I've been using it this way for 3 years now.

Here's your test project modified with changes that will let the EDMX Designer be opened in "SmokeTestNetCore". (Note the project open in the tab well)

image

If you change the EDMX file back to Microsoft.Data.SqlClient and then try to open it in the designer, you you will get a NullReferenceException.

image

ErikEJ commented 1 year ago

Ok, I will have a look at this advanced scenario but still you never replied to my question:

Are you able to open the designer in the unmodified NetFX smoke test project?

robertmclaws commented 1 year ago

Not with Microsoft.Data.SqlClient as the provider in the EDMX file. When I change it back to System.Data.SqlClient, it opens fine.

ErikEJ commented 1 year ago

I can open it just fine, so something is different on your machine(s).

And finding out what that could be seems more important to me before we move to Advanced, unsupported Configurations;

https://learn.microsoft.com/en-gb/ef/ef6/what-is-new/#ef-designer-support

What error do you get when you try to open the designer in the unmodified NetFX project?

Have you looked in the AciivityLog.xml file?

robertmclaws commented 1 year ago

It does not work on a clean Windows 11 system, version 25309.1000, with a clean Visual Studio 17.5.1 installed. The error message it presents is the same as my screenshot above.

This seems relevant from the ActivityLog.xml: image

ErikEJ commented 1 year ago

Thanks.

I am running Windows 10 with VS 17.5.1. Do you have a Windows 10 test machine/VM available?

robertmclaws commented 1 year ago

No, I do not. Maybe it's a good opportunity for you to spin up a Windows 11 VM? I know that Hyper-V Quick Create has a Windows 11 Dev VM on there that might be good.

ErikEJ commented 1 year ago

The designer opens fine for me on a clean, new VS image from Azure with Windows 11.

robertmclaws commented 1 year ago

All it gives me is the message in the 2nd screenshot. I don't have a stack trace. Debugging a VS instance with another VS instance does not produce a stack trace.

What .NET Frameworks are installed on that instance?

ErikEJ commented 1 year ago

What .NET Frameworks are installed on that instance?

Is there not only one?

Maybe you can share your machine.config file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config (privately if you prefer) and I can do a compare

robertmclaws commented 1 year ago

There are definitely more than one. image

My machine.config in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config is identical to machine.config.default.

ErikEJ commented 1 year ago

Ah, you mean targeting packs for Visual Studio. Let me check

ErikEJ commented 1 year ago

@robertmclaws I have these:

image

robertmclaws commented 1 year ago

I did a full VS repair, and on that Windows 11 with VS 2022 Professional 17.5.1, it will not open the model with Microsoft.Data.SqlClient.

I also downloaded the Windows 11 dev image from Hyper-V, updated it with the EF6 tools, and opened my fork of the project and got a NullReferenceException in the SmokeTestNetFx project.

That's 4 different machines on my end, all with the same result. Not a coincidence.

ErikEJ commented 1 year ago

@robertmclaws I really appreciate all your effort, but sadly I have now tried on two machines and am unable to repro. Really annoying.

A Teams meeting perhaps, if you are interested in taking this further?

robertmclaws commented 1 year ago

Sure! Want to DM me on Twitter and we'll set it up?

robertmclaws commented 1 year ago

Question, are you opening from my repo or yours?

ErikEJ commented 1 year ago

I am always opening from my unmodified repo

robertmclaws commented 1 year ago

We'll go over it on a call, but I spent like 2 hours putting together a consistent reproduction of the issue for you in a forked repo. I linked to it a while back, but here it is again: https://github.com/CloudNimble/EntityFramework6PowerTools/commit/07230f3fbd009e8e45f7e7e77293e9de1dc74f11

ErikEJ commented 1 year ago

Yes, I saw that - but it just adds more complexity to the issue and is not a supported configuration.

robertmclaws commented 1 year ago

It still reproduces the issue in supported configurations.

ErikEJ commented 1 year ago

@robertmclaws Yes, for you, I know, so let us focus on that.

@ryanbrandenburg @CZEMacLeod @jasonmalinowski @ajcvickers @bricelam

ajcvickers commented 1 year ago

@ErikEJ I get a null ref exception with VS Community 17.5.3 and VS Enterprise 17.6.0 Preview 2:

image
ErikEJ commented 1 year ago

@ajcvickers Thanks for confirming.

ErikEJ commented 1 year ago

@ajcvickers Really odd that it works for me on two machines. I will try a third

CZEMacLeod commented 1 year ago

@ErikEJ Just checked with VS Pro 17.5.2 then 17.5.3 after updating Same thing on 17.5.2 but it worked on 17.5.3! image image

Literally did nothing different. Hit the update on close notification. Closed VS. Updated. Reopened VS and the solution as before, then just double clicked the Model1.edmx (as before). Was expecting the same result but no. Sorry to muddy the waters here! Only thing I can think of is if I tried to open it too 'early' (before package restore completed maybe?) the first time, and the second time it had had time to complete the loading and restore.

CZEMacLeod commented 1 year ago

@robertmclaws @ErikEJ For reference, I also have many projects that are SDK style containing edmx files (I extract them from the migration resx file so I can view the model as a reference if I need to - they have Build Action = None). As long as I single target Net framework or multitarget with framework first they seem to open just fine.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net47;netstandard2.1</TargetFrameworks>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>

These are using the System.Data.SqlClient provider just now, but I am looking to change that in the future, once this package is fully released and I have some time to ensure I can make the switch without breaking any of my other code.

ErikEJ commented 1 year ago

@CZEMacLeod I would imagine a package restore and background build would be needed, as the provider is enabled via app config in the test app itself. Much appreciate your time!

ErikEJ commented 1 year ago

@ajcvickers @robertmclaws Are you able to get the latest community branch commits and give it another try, I just made some small adjustments.

ErikEJ commented 1 year ago

@CZEMacLeod Genius! I was finally able to repro by nuking the packages folder! Unloading/reloading the solution or project removed yellow warning signs from the references node, and then I was able to open the designer. Patience, my dear 😄

robertmclaws commented 1 year ago

I'm glad we're starting to make progress, and that more than 1 person has validated a) my issue, and b) my use case.

I just want to point out that you would have found this problem sooner if you had pulled down my branch, which would not have had compiled binaries in the bin folder, and then tried opening the model before compiling.

ErikEJ commented 1 year ago

@robertmclaws So are you able to open The designer now??

ErikEJ commented 1 year ago

@ryanbrandenburg Maybe the error message could be improved here?

ErikEJ commented 1 year ago

@robertmclaws Assume you got the 4th machine running then?