Can't update rows in my database using Entity Framework...?

Posted by Dissonant on Stack Overflow See other posts from Stack Overflow or by Dissonant
Published on 2010-05-15T16:42:23Z Indexed on 2010/05/15 16:44 UTC
Read the original article Hit count: 188

Filed under:
|
|
|
|

Okay, this is really weird. I made a simple database with a single table, Customer, which has a single column, Name. From the database I auto-generated an ADO.NET Entity Data Model, and I'm trying to add a new Customer to it like so:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main()
        {
            Database1Entities db = new Database1Entities();
            Customer c = new Customer();
            c.Name = "Harry";
            db.AddToCustomer(c);
            db.SaveChanges();
        }
    }
}

But it doesn't persist Customer "Harry" to the database! I've been scratching my head for a while now wondering why such a simple operation doesn't work. What on earth could be the problem!?

© Stack Overflow or respective owner

Related posts about database

Related posts about crud