One to One relationship not saving

Posts   
 
    
mrpmorris2
User
Posts: 1
Joined: 14-Feb-2018
# Posted on: 14-Feb-2018 18:13:46   

I have a [User] table, and a [UserSettings] table. Both are keyed on an ID column. There is a foreign key from UserSettings.Id to User.Id.

I imported this SQL Server database using LLBLGEN Pro it correctly generated a one-one relationship.

When I retrieve a User from the DataContext and set myUser.Settings = new UserSettings() and then call UpdateDatabase, the UserSettings instance is not saved.

I am wondering. When my ModelBuilder is generated (C#, EntityFrameworkCore) there is no config.Property definition for User to UserSettings, only from UserSettings to User, so I added this

config.HasOne(t => t.Settings).WithOne(t => t.User);

The DataContext.ChangeTracker shows only 1 entity (User) with a state of Unchanged.

Is this an EntityFrameworkCore bug, or do I need to ensure the ModelBuilder class defines the user differently to the attempt I made above?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Feb-2018 20:05:43   

Which version of LLBLGen Pro Designer are you using?

Could you please attach a repro LLBLGen project file, or create a Helpdesk thread and attach the one you are working on?

And post a code snippet of the entity creation and save procedure.