Try this:
var sql = @"Update [User] SET FirstName = @FirstName WHERE Id = @Id";
ctx.Database.ExecuteSqlCommand(
sql,
new SqlParameter("@FirstName", firstname),
new SqlParameter("@Id", id));
More Related Contents:
- Code-first vs Model/Database-first [closed]
- The relationship could not be changed because one or more of the foreign-key properties is non-nullable
- Should I enable or disable dynamic proxies with entity framework 4.1 and MVC3?
- How do I detach objects in Entity Framework Code First?
- ADO.NET DbContext Generator vs. ADO.NET Poco Entity Generator (ObjectContext)
- How to include a child object’s child object in Entity Framework 5
- Order navigation properties when using Include and/or Select methods with EF 4.1 Code-First?
- Entity framework code-first null foreign key
- How do you ensure Cascade Delete is enabled on a table relationship in EF Code first?
- Ramifications of DbSet.Create versus new Entity()
- Entity Framework 4.1 default eager loading
- EF Code First DBContext and Transactions
- How to update not every fields of an object using Entity Framework and EntityState.Modified
- Entity Framework Code First : Setting up One-To-One foreign key association using Annotations
- EF 4.1 loading filtered child collections not working for many-to-many
- Entity Framework Validation confusion – maximum string length of ‘128’
- Using the Entry().CurrentValues.SetValues() is not updating collections
- Entity Framework Code First Many to Many Setup For Existing Tables
- Entity Framework: One Database, Multiple DbContexts. Is this a bad idea? [closed]
- Entity Framework and SQL Server View
- How to filter nested collection Entity Framework objects?
- Unique keys in Entity Framework 4
- How to map table splitting in EF Code First?
- Entity Framework: Re-finding objects recently added to context
- ObjectContext.Refresh()?
- How do I map a char property using the Entity Framework 4.1 “code only” fluent API?
- mapping private property entity framework code first [duplicate]
- How to create index in Entity Framework 6.2 with fluent configuration
- Map two different entities to the same table?
- Nullable property to entity field, Entity Framework through Code First