In Entity Framework if you want to do an update without first getting the entity you should be able to use the DbContext.Entry
method like so:
var model = new MyModel() { Id = id, OtherData = data };
using (var db = new MyEfContextName())
{
db.MyModels.Attach(model);
db.Entry(model).Property(x => x.OtherData).IsModified = true;
db.SaveChanges();
}
This should tell EF to generate the appropriate UPDATE statement for you without having to SELECT the entity data at all.
On the other hand if you need to do a brief SELECT first in order to retrieve the Id for example, you could use an anonymous type when you select with Linq to Entities:
var existingData = db.MyModels.Where(x => x.SomeParameter == someValue).Select(x => new { Id = x.Id, OtherData = x.OtherData }).SingleOrDefault();
This will generate a SELECT statement which only selects the data you need and output it to an anonymous type.
And I should note that if you are doing complex queries or you are looking for efficiency then don't be afraid to use DbContext.Database.SqlQuery
or DbContext.Database.ExecuteSqlCommand
. Entity Framework won't support everything you might want to do and it's OK to go around it when needed.