I am using ASP.NET Core 2.2 with EF Core 2.2 and SQL server.
I am currently working on a feature where I have the following classes:
TABLE Foo
-------------------------------------------------------------
Column Type Remark
--------------------------------------------------------------
Id GUID PK
IntroId GUID? Nullable FK
IntroText Content Navigation Property
--------------------------------------------------------------
TABLE Content
--------------------------------------------------------------
Column Type Remark
--------------------------------------------------------------
Id GUID PK
Text string
--------------------------------------------------------------
This is my fluent API configuration related to my issue:
Foo
builder.HasOne(b => b.IntroText)
.WithOne()
.IsRequired(false);
Content
Content only has configuration for itself.
Content can contain a lot of text and because of reasons, these things are not saved directly in the Foo
table/class.
As you can see, I am trying to make sure that Content
does not have a foreign key/navigation property to Foo
. This is because these properties are not part of Content
and because in the future more classes/tables can have stuff like IntroText's that are saved in the Content
table and I dont want Content
to be filled up with nullable foreign keys/navigation properties.
Is this possible with EF Core?
The error I get right now:
The child/dependent side could not be determined for the one-to-one relationship between 'Foo.IntroText' and 'Content'. To identify the child/dependent side of the relationship, configure the foreign key property. If these navigations should not be part of the same relationship configure them without specifying the inverse. See http://go.microsoft.com/fwlink/?LinkId=724062 for more details.
I would accept an answer that allows the database to have a relationship which I do not see in my codebase, but I would prefer that Content
does not know anything about Foo
Thank you very much for your help!