您好我有两个具有导航属性的实体:
entity1 entity2
------ -------
entity1_id entity2_id
name location
loc entity1_id
----- -----------
Navigation properties Navigation properties
entity2 entity1
我有一个模型类:
public class Main
{
public string name {get: set:}
public string loc {get: set:}
public string location {get: set:}
public int entity1_id {get; set;}
}
在我的网页api中,我正在尝试编写这个模型
的记录public HttpResponseMessage Postentity1(Main main)
{
db.entity1.Add(main);
db.SaveChanges();
};
它不起作用。 main的值未保存。请让我知道如何保存记录。谢谢