msawczyn / EFDesigner

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
363 stars 60 forks source link

Entity Model Property Grid is blank #282

Closed SimGoesMad closed 3 years ago

SimGoesMad commented 3 years ago

Hi

If I select the "designer background" (i.e. the Entity Model), the Property Grid remains blank (see screenshot). I can add an entity to it and if I select that entity, the properties are displayed properly and I can edit them.

In addition, if I try to generate the code from the designer, I get this:

Running transformation: System.FormatException: Input string was not in a correct format. at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) at Sawczyn.EFDesigner.EFModel.ModelRoot.GetEntityFrameworkPackageVersionNum() in C:\Code\EFDesigner\src\Dsl\CustomCode\Partials\ModelRoot.cs:line 335 at Microsoft.VisualStudio.TextTemplating8BF535456DDDC7158A1AECBA7B16985C48D1A708045F66A681C85CA0FC84E32EDC0F7B7F839662540F3401A8D9ACEFE784ABEE1900F56C76F9FE05524999E626.GeneratedTextTransformation.TransformText() in ** - Model.tt:line 49

I've tried this on two different machines, in two different domains, with two different users and two different VS2019 setups (pro vs. enterprise & different extension collection) and it makes no difference.

What am I missing? My VS2019 is up to date and I have tried the project in question in both .netCore3.1 and .net5.0 configurations - no difference.

image

npagare commented 3 years ago

Hi @SimGoesMad , how are you ?

@michael-sawczyn @msawczyn wasn't doing well health wise as per his comments in one of the issues from last 2 months. Hope he is doing better now. His contribution is great to the community.

I am also waiting for his response.

JoySoft2 commented 3 years ago

I'm facing the same problem. Sawczyn.EFDesigner.EFModel.ModelRoot.GetEntityFrameworkPackageVersionNum() method gets the EF version, but the value isn't valid input for the System.Number.ParseDouble() method.

msawczyn commented 3 years ago

What is the value you have for Entity Framework Package Version in your designer properties?

JoySoft2 commented 3 years ago

My designer properties are empty if I click on the "designer background". image

This shows my project file references:

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.5">
SimGoesMad commented 3 years ago

@msawczyn as can be seen in the screen shot both I and @JoySoft2 posted, the properties are blank.

Should that be in the attributes of the modelRoot element of the .efmodel file?

Here's what I find: <modelRoot xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="3.0.4.7" Id="cba47279-0950-4257-bb2c-e4d5e72a52a4" entityContainerName="XXXX" namespace="XXXX" automaticMigrationsEnabled="false" showCascadeDeletes="false" databaseType="None" exposeForeignKeys="false" propertyAccessModeDefault="Field" generateDbContextFactory="false" showInterfaceIndicators="false" xmlns="http://schemas.microsoft.com/dsltools/EFModel">

JoySoft2 commented 3 years ago

Somehow we need to investigate the EXACT value returned by GetEntityFrameworkPackageVersionNum() method.

msawczyn commented 3 years ago

We've got two things going on: 1) the property window is blank when you access the design surface, and 2) the package version number is getting fouled up.

I see that I had some code changes that look like they were there to fix 2), and I've dropped a build at https://github.com/msawczyn/EFDesigner/raw/master/dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix that might be worth trying. I'd be curious to know if that fixes the issue. You can always see the value returned by that method by putting a breakpoint in the T4 file and running it. When the breakpoint's hit, you'll have your regular debugger available and can investigate application state as usual.

Regarding 1), there appears to have been a similar issue with WPF elements that was fixed in 16.9.1, but that may or may not have any bearing. That one's got me scratching my head, since it's something extensions have no control over. This happens with every model?

JoySoft2 commented 3 years ago

I downloaded and installed the package from the given URL, still no luck with it. Sadly, it doesn't fix any of the problems.

So I checked the EF version number at the ModelRoot object: efver Clearly, it's not a valid input for ParseDouble().

Edit: The GetEntityFrameworkPackageVersionNum() returns "6.0" for me. I played around with double.Parse() method. If I call this form: double.Parse("6.0") throws exception "Input string was not in a correct format". If I call this form: double.Parse("6.0", CultureInfo.InvariantCulture)... Bingo!! Maybe the problem is my Windows localisation settings (I am Hungarian). I think it will fix the problem.

msawczyn commented 3 years ago

@JoySoft2 - Great info. Yes, it does -- knowing that this was a CultureInfo problem was the key. I've posted another build to the dist folder (in the url posted above); please let me know if this resolves the package version issue.

Why the property window isn't showing the properties for the design surface is another problem altogether, and is definitely a visual studio configuration issue, possibly related to other extensions getting in the mix. Does anything show up in the visual studio logs?

JoySoft2 commented 3 years ago

@msawczyn Great news! Installed the package from the URL. It solves the package version error and the designer surface properties error too! Thank you for your fast and professional support!

msawczyn commented 3 years ago

Glad that worked. I'll publish that version to Marketplace today.

SimGoesMad commented 3 years ago

Sensational news - thank you all for participating & figuring this out. I'll be checking it out shortly. Much appreciated!