@BenAaronson, . Entity Framework , , β , , /. , EF , . :
public class MyClass
{
public int MyClassId { get; set; }
public int MyOtherClassId { get; set; }
}
, , EF , MyClassId MyClass, .
EF , , (, , ).
, , , EF - ( , Key1). :
context.MyTable.Attach(new MyObject() { Key1 = 100; Key2 = null; });
MyObject, 100 Key2 null.
:
context.MyTable.Attach(new MyObject() { Key1 = 100; Key2 = 2000; });
, 100, . , , , 100 ( ).
Key2 null , , . @BenAaronson :
public class Object
{
[Key]
private int ObjectID { get; set; }
public int Key1 { get; set; }
public int Key2 { get; set; }
}
:
context.MyTable.Add(new MyObject() { Key1 = 100, Key2 = null; });
context.MyTable.Add(new MyObject() { Key1 = 100, Key2 = 2000; });
. Add, Attach. , Attach , , , ; , , context.SaveChanges(). Attach Unmodified. , . , . Add. Added. , . , Added, context.SaveChanges(), , Unmodified.
. " ", EF ( , . ). , --. " ". , , .
, : (.. ) ( , , ), . EF . , , ( , ), . :
public class A
{
public int ID { get; set; }
}
public class B
{
public int ID { get; set; }
}
public class AToB
{
[Key]
public int IdA { get; set; }
[Key]
public int IdB { get; set; }
public A SideA { get; set; }
public B SideB { get; set; }
public DateTime Created { get; set; }
}
, EF . :
myA.AToB.SideB
myA.AToB.Created
, , , EF .
Entity Framework.