Closed omatrot closed 1 year ago
This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. In particular, the, "// Data layer code not shown here." is likely to be relevant.
I will close this issue because running EF Core 3.1 on NET 7 is possible.
@omatrot Note that EF Core 3.1 is out-of-support.
First of all, I'm in a Database First context, so I cannot provide a reproductible sample. I have been using the scaffolding tool to generate the entities and the DBContext. This is a migration from an existing data layer from EF 3.1 to EF 7. All I have done for EF 7, is to include all the existing code, and embedd it in a NET 7 library. I can't alter the database if this is needed to fix my bug.
In EF 3.1 I was doing the following to create ad persist a small graph:
Then the Vehicle is added to the context for saving. It is working fine in EF 3.1, but in EF 7 I have the following error:
Indeed, there is a relationship from Registration to Vehicle.
If I do the reverse, first create the Registration and then associate a new Vehicle, inserting works.
Following are the entities and the configuration: