What is the syntax in linq for inserting a record using ObjectSet <> instead of using .AddToXXXXX (MyEntity), as it is deprecated?

I am new to Linq for Entities, and I am trying to insert a record using linq syntax.

I created the edmx file and installed it in the class using:

    PasswordEntities db = new PasswordEntities();

I have a method that looks like this:

    public void InsertRecord(Password record)
    {
        db.AddToPasswords(record);
    }

But intellisense tells me that AddToPasswords is an obsolete method and should instead use the .Add method of the associated ObjectSet property.

I am running VS 2010 under Framework 4.0.

What will be the syntax for this?

+3
source share
2 answers

What about:

db.Passwords.AddObject(record);

: Object OO, EF. , , , . ObjectContext , ?

+8

. AddToPasswords() . ?

add (, db ObjectContext):

public void InsertRecord(Password record)
{
    db.AddObject("EntitySetName", record);
}
+1

Source: https://habr.com/ru/post/1748534/


All Articles