开发者

entity framework mark as modified code first 5

开发者 https://www.devze.com 2023-02-09 05:24 出处:网络
Marking a property as modified should be done like this: using (var context = new UnicornsContext()) { var unicorn = context.Unicorns.Find(1);

Marking a property as modified should be done like this:

using (var context = new UnicornsContext())
{
    var unicorn = context.Unicorns.Find(1);
    var nameIsModified1 = context.Entry(unicorn).Property(u => u.Name).IsModified;

    // Use a string for the property name
    var nameIsModified2 = context.Entry(unicorn).Property("Na开发者_如何学运维me").IsModified;
}

code sample from here

In my code UnicornsContext extends DBContext.

I don't have a Entry method for my context. whats's wrong?

0

精彩评论

暂无评论...
验证码 换一张
取 消