It's DbDatabase! (Updating for changes to database creation APIs)

This commit is contained in:
ajcvickers 2014-04-28 15:10:34 -07:00
parent b7a989256f
commit 30dac08fe8
1 changed files with 2 additions and 6 deletions

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Data.Migrations;
using Microsoft.Data.Relational;
using Microsoft.Data.SqlServer; using Microsoft.Data.SqlServer;
using MusicStore.Models; using MusicStore.Models;
@ -18,14 +16,12 @@ namespace MusicStore.Web.Models
{ {
using (var db = new MusicStoreContext(serviceProvider)) using (var db = new MusicStoreContext(serviceProvider))
{ {
// TODO [EF] Swap to use top level API when available
var sqlServerDataStore = db.Configuration.DataStore as SqlServerDataStore; var sqlServerDataStore = db.Configuration.DataStore as SqlServerDataStore;
if (sqlServerDataStore != null) if (sqlServerDataStore != null)
{ {
var creator = new SqlServerDataStoreCreator(sqlServerDataStore, new ModelDiffer(), new SqlServerMigrationOperationSqlGenerator(), new SqlStatementExecutor()); if (!await db.Database.ExistsAsync())
if (!await creator.ExistsAsync())
{ {
await creator.CreateAsync(db.Model); await db.Database.CreateAsync();
await InsertTestData(serviceProvider); await InsertTestData(serviceProvider);
} }
} }