user2516261
user2516261

Reputation: 73

Insert operation in Ef with LINQ

I am a beginner in Entity framework and I want to insert operation through Linq To entity.

My code:

databaseentity entity = new databaseentity();
car c = new car { name = TextBox1.Text };

But when I write Addobject in code it shows error and this method is not supported by Ef:

entity.cars.AddObject(c);

How can I resolve this problem? I have already added system.data.objects namespace.

Upvotes: 0

Views: 100

Answers (1)

Ali Baghdadi
Ali Baghdadi

Reputation: 648

Try using

entity.AddToCars(c);
entity.SaveChanges();

Upvotes: 1

Related Questions