user6824563
user6824563

Reputation: 815

asp.net Entity Data Model doesn't have submitChanges

I start to work with LINQ, but my DbContext doesn't have the submitChanges method. It should be default in the class. Right?

    using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

public partial class LibraryEntities : DbContext
{
    public LibraryEntities()
        : base("name=LibraryEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }

    public virtual DbSet<User> Users { get; set; }
    public virtual DbSet<MSreplication_options> MSreplication_options { get; set; }
    public virtual DbSet<spt_fallback_db> spt_fallback_db { get; set; }
    public virtual DbSet<spt_fallback_dev> spt_fallback_dev { get; set; }
    public virtual DbSet<spt_fallback_usg> spt_fallback_usg { get; set; }
    public virtual DbSet<spt_monitor> spt_monitor { get; set; }
    public virtual DbSet<Book> Books { get; set; }
}

When I try to call the SubmitChanges, it says that the method does not exist. Does anyone know why?

int id = (int)HttpContext.Current.Session["userId"];

    var query = (from u in db.Users
                 where u.Id == id
                 select u).FirstOrDefault();

    query.FirstName = firstNameModal.Text;

    db.SubmitChanges();

Upvotes: 0

Views: 602

Answers (1)

christophano
christophano

Reputation: 935

The method you're looking for is called SaveChanges.

Upvotes: 2

Related Questions