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

unidirectional association 1 to 1 not accpeted by EFc5 or EFDesigner #252

Closed
pas059 opened this issue Dec 22, 2020 · 23 comments
Closed

unidirectional association 1 to 1 not accpeted by EFc5 or EFDesigner #252

pas059 opened this issue Dec 22, 2020 · 23 comments
Labels
investigating Looking into this
Projects
Milestone

Comments

@pas059
Copy link

pas059 commented Dec 22, 2020

Hello,

I updated an app using Net 4.7.2 + EFc 3.1 to Net 5 + EFc 5; without asking EFDesigner to regenerate the files, everything run fine.

Today, i also updated EFDesinger to the latest version, and changed the 'Entity Framework Package Version' of my 'efmodel' to the '5.0.Latest'; this produces an error each time i have an 1 to 1 unidirectional association between en entity and a dependant entity. The error messages are like this one:
Organization.Address --> Address: The association from Address to Organization must be 1..0-1

Is this caused by a changes in EFc 5 that i did not saw or by the new version EFDesigner?

Regards

@msawczyn
Copy link
Owner

Unfortunately, EFCore5 doesn't yet support N-to-N unidirectional associations.

@msawczyn msawczyn added the question Requesting information label Dec 22, 2020
@pas059
Copy link
Author

pas059 commented Dec 22, 2020

hi,
ok, but in my case this is not n to n, but 1 to 1. This is something that works with EFc 3.

@pas059
Copy link
Author

pas059 commented Dec 23, 2020

Hi,
perhaps i not explained correctly the problem. I encounter this error, for 1 to 1 unidirectional association between en entity and a owned (dependant) entity. Fortunately, this kind of association is allowed by EFc 5 even if there is a litle improvement on this feature. For the 1 to 1 unidirectional associations between 2 entities, no error are signaled.

Regards

@msawczyn
Copy link
Owner

msawczyn commented Jan 2, 2021

Thanks for the clarification. Using 3.0.2, I can't seem to reproduce the error (assuming I understand it correctly now). When I try the following
1-1
the designer accepts it and generates

         modelBuilder.Entity<global::Sandbox_EFCore5NetCore3_Test.Entity1>().ToTable("Entity1").HasKey(t => t.Id);
         modelBuilder.Entity<global::Sandbox_EFCore5NetCore3_Test.Entity1>().Property(t => t.Id).ValueGeneratedOnAdd().IsRequired();
         modelBuilder.Entity<global::Sandbox_EFCore5NetCore3_Test.Entity1>().OwnsOne(p => p.Entity2).Property(p => p.SomeProperty).IsRequired();
         modelBuilder.Entity<global::Sandbox_EFCore5NetCore3_Test.Entity1>().Navigation(p => p.Entity2).IsRequired();

         modelBuilder.Owned<global::Sandbox_EFCore5NetCore3_Test.Entity2>();

and the subsequent migration is

            migrationBuilder.CreateTable(
                name: "Entity1",
                schema: "dbo",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Entity2_SomeProperty = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Entity1", x => x.Id);
                });

If you could make available a small model file showing the problem that would be really helpful in tracking this down.

Thanks.

@msawczyn msawczyn added investigating Looking into this need info Need more information to track this down no repro Can't reproduce. Need sample code that exhibits the issue. and removed question Requesting information labels Jan 2, 2021
@msawczyn msawczyn added this to Enhancement Requests in EFDesigner via automation Jan 2, 2021
@msawczyn msawczyn moved this from Enhancement Requests to Bug Reports in EFDesigner Jan 2, 2021
@msawczyn msawczyn moved this from Bug Reports to Active in EFDesigner Jan 2, 2021
@msawczyn msawczyn removed the investigating Looking into this label Jan 2, 2021
@pas059
Copy link
Author

pas059 commented Jan 4, 2021

Hello,
first of all, i wish you a happy new year.

I made a little project that recreates the issue. You can download it by following this link.

Regards

@msawczyn
Copy link
Owner

msawczyn commented Jan 9, 2021

Thanks for the file, and a happy new year to you too! I was able to open the model and generate code without any issues. Possibly whatever was causing the problem was fixed by another change.

I'll close this for now and ask you to give it a try with the next release, which should be out today or later this weekend. If you still encounter problems, please feel free to reopen.

@msawczyn msawczyn closed this as completed Jan 9, 2021
EFDesigner automation moved this from Active to Done Jan 9, 2021
@pas059
Copy link
Author

pas059 commented Jan 29, 2021

Hello,
I installed the latest version. Now this works when the selected 'Entity Framework package Version' is set to 'latest', but this does not work with others selections, even with 3.1.11.

regards

@msawczyn msawczyn reopened this Feb 11, 2021
EFDesigner automation moved this from Done to Enhancement Requests Feb 11, 2021
@msawczyn
Copy link
Owner

That's a limitation of the previous version.
See https://docs.microsoft.com/en-us/ef/core/modeling/owned-entities
In EF Core 3.x the columns for owned entity types mapped to the same table as the owner are always marked as nullable.

EFDesigner automation moved this from Enhancement Requests to Done Feb 11, 2021
@pas059
Copy link
Author

pas059 commented Feb 11, 2021

Hi,
i don(t think that this is the cause of the issue, because even when i select the 'Entity Framework package Version' as 5.0.latest, this not works.
This is a problem because using such '1 to 1' associations with the 'Entity Framework package Version' other than the 'latest' is not possible with EF-Designer v3, while this was possible without problems for instance with EF-Designer v2.0.5.7 targetting EFcore 3.1.x.

best regards

@msawczyn
Copy link
Owner

msawczyn commented Feb 12, 2021

There is an issue with the designer and its mapping of capabilities to the selected EF version that's (hopefully) fixed in 3.0.4, the RC1 being available at https://github.com/msawczyn/EFDesigner/raw/master/dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix

If you could give that file a try, I'd be in your debt.

@msawczyn msawczyn added this to the 3.0.4 milestone Feb 13, 2021
@msawczyn msawczyn added pending release Issue is resolved in the current codebase, will be published with the next release and removed need info Need more information to track this down no repro Can't reproduce. Need sample code that exhibits the issue. labels Feb 13, 2021
@pas059
Copy link
Author

pas059 commented Feb 15, 2021

Hello,
i installed this version (3.0.4.5), but now i can not display the properties of the model, and so i could not change the EFc target, so i reinstalled the v3.0.3.2.
Nevertheless, i just noticed, that when "Entity Framework Version" is "EFCore", the field "Entity Framework package Version" could be 6.0.0 (??? I didn't even know it existed). So i imagine that when i select "Entity Framework package Version" as "latest" this the version 6 and not 5!

Someone can tell to microsoft to stop announce a new major version while the current version is not already stable.

best regards

@msawczyn
Copy link
Owner

LOL. No fear. While the Nuget package for v6 exists, and therefore is detected by the designer and shown in the property selector, there is currently no support for anything new in v6 for code generation or new features.

I am concerned, however by your report of but now i can not display the properties of the model. That's nothing neither I've seen nor any other user has encountered. Do you mean that, when opening an .efmodel file it doesn't open, or when you get it open you can't select anything (including the design surface) and get the property window to display that selection's properties?

@pas059
Copy link
Author

pas059 commented Feb 19, 2021 via email

@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
@msawczyn
Copy link
Owner

@pas059 - we need to diagnose this by process of elimination. Let's try something, if you're willing.

Create a new model file in that or some other project. Can you view/edit the designer surface properties there?
If yes, would you be able to get me a copy of the model file where you can't view those properties so that I can try to open it? If it's an error in the model file, I may be able to fix that for you.

If you still can't view those properties on a new model, grab one of the models in the testing solution (under https://github.com/msawczyn/EFDesigner/tree/master/src/Testing) and try it. Those work fine for me.

@pas059
Copy link
Author

pas059 commented Feb 25, 2021

Hello,
sorry to reply late.
Now my devlopment environnement is VS2019CE Vers 16.8.6 and EFDesigner 3.0.4.7.
This changes nothing. I tried with the testing project EFCore5Net5, and this makes the same thing. I can open and display the model, display the properties of the entitie, but not the properties of the model.

An idea?
best regards

@pas059
Copy link
Author

pas059 commented Feb 25, 2021

hello again,
i lso tried to create a new model, ... the same result.
best regards

@pas059
Copy link
Author

pas059 commented Feb 26, 2021

Hello,
As i wondered where are defined these properties that EFDesigner does nt display, and assuming that they are defined in the .efmodel file, i displayed the .efmodel files with a xml editor and i noticed that some attributes of the 'modelRoot' element are missing; they are: entityFrameworkVersion and entityFrameworkPackageVersion. But even after added these atributes by comparison from a backup file, EFDesigner still does not display the properties.

If this can help
Best regards

@msawczyn msawczyn reopened this Feb 27, 2021
EFDesigner automation moved this from Done to Enhancement Requests Feb 27, 2021
@msawczyn msawczyn moved this from Enhancement Requests to Active in EFDesigner Feb 27, 2021
@msawczyn
Copy link
Owner

I'm trying to get back in the swing of things again ... was this ever resolved? I see it's tagged as Released, so I'm guessing it was, although I don't want to close it without confirmation.

@pas059
Copy link
Author

pas059 commented May 5, 2021

Hi,

now my devlopment environnement is VS2019CE Vers 16.9.4 and EFDesigner 3.0.4.7.
The situation is worse. For some project, it not possible to get/edit the model's properties as explain above, and for others when trying to open the model i've got an error : "le format de la chaine d'entrée est incorrect" which can be translated by "the format of the input string is incorrect ".

In both cases, this makes EFDesigner unusable. No emergency for my current app which does not changes from the DB point of view, but very soon i'd like to migrate to EFc5 (6?) ....

Regards

@msawczyn
Copy link
Owner

msawczyn commented May 5, 2021

i noticed that some attributes of the 'modelRoot' element are missing

If a property is the same as the default, as defined in the DSL code, it's not written to the XML file, so you won't see it there.

@msawczyn
Copy link
Owner

msawczyn commented May 5, 2021

We need to divide this problem up and start eliminating possibilities. Would you be willing to send me a file you can't open correctly? I'll see what it does on my computer.

@msawczyn msawczyn added investigating Looking into this and removed released Issue is resolved in a current release labels May 6, 2021
@pas059
Copy link
Author

pas059 commented May 6, 2021 via email

@pas059
Copy link
Author

pas059 commented May 17, 2021

Hi,
I just updated to EF Designer 3.0.5.2 and this works, i can open the models that i could no longer open, and now i can see and change the properties of the models. Then, i also updated to VS 2019CE 16.9.5 and this continue to work. Yeah!!
Regards

EFDesigner automation moved this from Active to Done May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
investigating Looking into this
Projects
EFDesigner
  
Done
Development

No branches or pull requests

2 participants