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