Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Where is my AddOrUpdate function?

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

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

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!?

Here's a screen grab...

No .AddOrUpdate

like image 808
Ray Brennan Avatar asked Sep 13 '15 16:09

Ray Brennan


1 Answers

That's an IDbSetExtensions extension method.

You need to add a using System.Data.Entity.Migrations; directive.

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.

like image 90
CodeCaster Avatar answered Oct 06 '22 13:10

CodeCaster