I have an entity called Tree, which has a primary key called Id (with StoreGeneratedPattern = Identity) that when using the following code, correctly inserts into the database.
using(TestContainer tss = new TestContainer())
{
Tree tree = new Tree()
{
Name = "TestTree"
};
tss.Trees.AddObject(tree);
tss.SaveChanges();
}
I have a backing sequence + trigger to handle the auto incremented primary key Id. I have verified that this actually inserts into the database correctly.
Calling tss.Refresh(System.Data.Objects.RefreshMode.StoreWins, tree);
does not update the object (the 'Id' field is still 0). Any ideas?
<EntityType Name="Tree">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="String" Name="Name" Nullable="false" />
<NavigationProperty Name="HeuristicCulls" Relationship="TOPSSSimpleSelect.TreeHeuristicCull" FromRole="Tree" ToRole="HeuristicCull" />
<Property Type="Int32" Name="Type" Nullable="false" />
<NavigationProperty Name="PR_T" Relationship="TOPSSSimpleSelect.PR_TTree" FromRole="Tree" ToRole="PR_T" />
<NavigationProperty Name="TreeItems" Relationship="TOPSSSimpleSelect.TreeTreeItem" FromRole="Tree" ToRole="TreeItem" />
<Property Type="Byte" Name="IsRoot" Nullable="false" />
<Property Type="Byte" Name="IsProductRoot" Nullable="false" />
<NavigationProperty Name="TreeProducts" Relationship="TOPSSSimpleSelect.T_TP" FromRole="Tree" ToRole="TreeProducts" />
</EntityType>
<EntityType Name="TreeItem">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<NavigationProperty Name="Questions" Relationship="TOPSSSimpleSelect.TI_Q" FromRole="TreeItem" ToRole="Question" />
<Property Type="String" Name="Name" Nullable="false" />
<NavigationProperty Name="SubmitRules" Relationship="TOPSSSimpleSelect.SubmitRuleTreeItem" FromRole="TreeItem" ToRole="SubmitRule" />
<NavigationProperty Name="PR_TI" Relationship="TOPSSSimpleSelect.PR_TITreeItem" FromRole="TreeItem" ToRole="PR_TI" />
<NavigationProperty Name="Tree" Relationship="TOPSSSimpleSelect.TreeTreeItem" FromRole="TreeItem" ToRole="Tree" />
<Property Type="Int32" Name="TreeId" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="Byte" Name="IsRoot" Nullable="false" />
</EntityType>