How add entity from table many to many
Create entity Desk:
var desk = new Desk()
{
x = Convert.ToInt32(Canvas.GetLeft(item)),
y = Convert.ToInt32(Canvas.GetTop(item)),
width = item.Width,
height = item.Height,
};
Add to table Desks:
m_RoomsContext.Desks.Add(desk);
And I need add desk.id and other id_room, but desk.id == 0.
m_RoomsContext.RoomToStandartDesks.Add(new RoomT开发者_StackOverflow社区oStandartDesk()
{
id_room = int.Parse(btnSave.Tag.ToString()),
id_desk = desk.id
}
);
How update desk ? or how to do it?
I think you're looking to update the changes to entities? If so:
m_RoomsContext.SaveChanges();
精彩评论