using c# entity framework 7 with sqlite, how can I check to see if a table exists and if not create it? Maybe based off a dbset that is in the context? There is no existing database with a migration or anything. The app just creates the database when its not there and I'd like to to also create the tables.
public class Context : DbContext
{
public DbSet<Value> Values { get; set; }
protected override async void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Filename=data.db");
//here somewhere?
}
}
If you are not using migrations, you can use this in your app startup procedure:
context.Database.EnsureCreated();
Or with Migrations:
context.Database.Migrate();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.