It's DbDatabase! (Updating for changes to database creation APIs)
This commit is contained in:
parent
b7a989256f
commit
30dac08fe8
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue