I am trying to perform an insert with EF 6.
I checked that I have a database connection because I can read:
List<Driver> drivers = DataContext.Drivers.ToList();
With sql profiler, I see that it makes a selection in the database and returns the item that I manually inserted.
I am trying to do an insert like this:
var driver = new Driver();
driver.DriverName = "Blah";
DataContext.Drivers.Add(driver);
DataContext.ChangeTracker.HasChanges();
DataContext.SaveChanges();
but nothing is inserted, and changetracker seems to indicate that it has not detected any changes. I also saw suggestions to use .Attach, but it had the same results.
Any help on what I'm doing wrong?
Greetings
(MyEntities.Context.cs)
public partial class MyEntities : DbContext
{
public MyEntities()
: base("name=MyEntities")
{
}
public partial class MyDataContext : MyEntities
{
public class SqlDataService : DataServiceBase<...Data.MyDataContext>
{
edit: Don't use the code first (not what I know!), not sure if the above code examples help, but show how I set up my classes