LinqToSQL not updating database

Posted by codegarten on Stack Overflow See other posts from Stack Overflow or by codegarten
Published on 2010-05-18T16:59:39Z Indexed on 2010/05/18 17:00 UTC
Read the original article Hit count: 277

Hi.

I created a database and dbml in visual studio 2010 using its wizards. Everything was working fine until i checked the tables data (also in visual studio server explorer) and none of my updates were there.

using (var context = new CenasDataContext())
{
    context.Log = Console.Out;
    context.Cenas.InsertOnSubmit(new Cena() { id = 1});
    context.SubmitChanges();
}

This is the code i am using to update my database. At this point my database has one table with one field (PK) named ID.

*INSERT INTO [dbo].Cenas VALUES (@p0) -- @p0: Input Int (Size = -1; Prec = 0; Scale = 0) [1] -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 4.0.30319.1*

This is LOG from the execution (printed the context log into the console).

The problem i'm having is that these updates are not persistent in the database. I mean that when i query my database (visual studio server explorer -> new query) i see the table is empty, every time.

I am using a SQL Server database file (.mdf).

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about visual-studio-2010