Background: I have a connection from 1 to 0..1 between User and UserSettings .. p>
The important part of the model is as follows:
public class User
{
public int UserId { get; set; }
public string Name { get; set; }
public UserSettings Settings { get; set; }
}
public class UserSettings
{
public int UserId { get; set; }
public sting SpecialField { get; set; }
}
When I do INSERT :
var user = new User { Settings = new UserSettings { SpecialField = "Foo" }};
ctx.Users.Add(user);
ctx.SaveChanges();
Everything is cool, when I check the trace, User is added first , then UserSettings - as you would expect, since UserSettings requires IDENTITY from the User .
But when I UPDATE that "SpecialField":
var user = ctx.Users.Include("Settings").Single();
user.Name = "Joe";
user.Settings.SpecialField = "Bar";
ctx.SaveChanges();
, EF, UserSettings, .
?
, , SpecialField, .
- ? ( , "" , ).