Reputation: 2589
I've read all posts that I could find related to this subject and applied their solutions, but still the DeleteOnSubmit() method does not show as an option. DeleteObject() doesn't either. Using EF 6.1.3, NET 4.5 and VS 2013. I've also added a reference to System.Data.Link. Here is part of the code, simplified for clarity:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Linq;
public void DeleteRow(int rowId)
{
using (AppDataDbContext db = new AppDataDbContext())
{
db.Reservations.?????
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
public class AppDataDbContext: DbContext
{
public AppDataDbContext()
: base("name=DefaultConnection")
{
}
public DbSet<Reservation> Reservations { get; set; }
}
enter code here
public class Reservation
{
[Key()]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdNo { get; set; }
public int ClientAcctNo { get; set; }
public string Description { get; set; }
public DateTime DueDate { get; set; }
public string Status { get; set; }
}
Upvotes: 0
Views: 292
Reputation: 3009
You are using Linq to Entity Framework not Linq to SQL so what you can do instead is just use the Remove() method which achieves the same goal.
db.Reservations.Remove(your entity)
db.SaveChanges();
The entities will not be deleted until the SaveChanges is called so you can call Remove in a loop or RemoveRange.
Upvotes: 1
Reputation: 3009
Are you sure that LogEvents is a 'Table'? DeleteOnSubmit can only be called from a 'Table'.
Upvotes: 1