An error occurred while saving entities that do not expose foreign key properties for their relationships

后端 未结 15 1363
难免孤独
难免孤独 2020-12-08 02:43

I have a simply code in Entity Framework 4.1 code first:

PasmISOContext db = new PasmISOContext();
var user = new User();
user.CreationDate = Da         


        
15条回答
  •  太阳男子
    2020-12-08 03:03

    I had the same error and in my case the problem was that I added a relationship object which had already been loaded "AsNoTracking". I had to reload the relation property.

    BTW, Some suggest using "Attach" for relations that already exist in db, I haven't tried that option though.

提交回复
热议问题