I'm using WAF ( WPF Application Framework ) in here: https://waf.codeplex.com. And I open the BookLibrary project in it sample. I have an model named Author and it related class.
And this is it DbContext:..
internal class BookLibraryContext : DbContext
{
public BookLibraryContext(DbConnection dbConnection)
: base(dbConnection, false)
{
Database.SetInitializer<BookLibraryContext>(null);
}
public BookLibraryContext()
: base(@"Data Source=|DataDirectory|\Resources\BookLibrary2.sdf")
{
}
public bool HasChanges
{
get
{
ChangeTracker.DetectChanges();
// It is necessary to ask the ObjectContext if changes could be detected because the
// DbContext does not provide the information when a navigation property has changed.
return ObjectContext.ObjectStateManager.GetObjectStateEntries(EntityState.Added).Any()
|| ObjectContext.ObjectStateManager.GetObjectStateEntries(EntityState.Modified).Any()
|| ObjectContext.ObjectStateManager.GetObjectStateEntries(EntityState.Deleted).Any();
}
}
private ObjectContext ObjectContext { get { return ((IObjectContextAdapter)this).ObjectContext; } }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Configurations.Add(new PersonMapping());
modelBuilder.Configurations.Add(new BookMapping());
modelBuilder.Configurations.Add(new AuthorMapping());
}
}
When i run the project. An exception occured:
{"The specified table does not exist. [ Author ]"}
How do i add new table named Author ? I know using Entity Framework migration or edit the database structor with tools.
But I see the method named HasChange(). It may do something to reflect my database. But I don't know to make it work. Please help me