实体框架AddOrUpdate函数在哪里? [英] Entity Framework Where is my AddOrUpdate function?

查看:58
本文介绍了实体框架AddOrUpdate函数在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Entity Framework 6.1.3针对SQL Server 2012 db在VS2015 WCF服务中工作

I'm working in VS2015 WCF service against a SQL Server 2012 db with Entity Framework 6.1.3

我从现有数据库中的代码优先入手,从那以后,就可以从CF中进行所有编辑了。

I started out with "Code First from Existing Database" and since then do all edits from CF.

我有基本的读写操作。我可以将它添加到表中,并且可以按预期运行,但是我不能看到.AddOrUpdate,因为我看到有人在谈论它,因为键入时它不在智能感知下拉列表中!?

I have basic read write operations working. I can .Add to a table fine and it works as expected but I can't .AddOrUpdate as I see people talking about because it's not in the intellisense dropdown as I type!?

这是屏幕抓取...

推荐答案

这是 IDbSetExtensions 扩展方法

That's an IDbSetExtensions extension method.

您需要添加使用System.Data.Entity.Migrations; 指令。

此处以及其他各种来源(只需在网络上搜索 AddOrUpdate实体框架),该方法仅用于播种。不要在应用程序逻辑中使用它。

As explained here and in various other sources (just search the web for '"AddOrUpdate" entity framework') this method is meant to be used for seeding only. Don't use it in your application logic.

这篇关于实体框架AddOrUpdate函数在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆