Add-Migration EntityFramework Core 2.0 trying to select from table in an empty database

.net-core asp.net-core entity-framework-core

Question

I'm trying to run the add-migration command for my database context and for some reason it's trying to do a select on a table that doesn't even exist yet (running on an empty database). The command I'm running is:

Add-Migration -context MyDbContext MyDb-1.0

I immediately get an error:

An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: Invalid object name 'AccountTypes'.

Looking at the stacktrace I see the command was trying to do a select statement on a non-existing (yet) table:

fail: Microsoft.EntityFrameworkCore.Database.Command[200102]
      Failed executing DbCommand (27ms) [Parameters=[@__value_0='?'], CommandType='Text', CommandTimeout='30']
      SELECT TOP(1) [p].[Id], [p].[AccountType]
      FROM [AccountTypes] AS [p]
      WHERE [p].[Id] = @__value_0

Not sure what is going on here. I'm using ASP.NET core 2.0 with EF core 2.0. I didn't have a problem doing this with core < 2.0.

Any ideas?

1
1
8/30/2017 2:55:38 PM

Popular Answer

1
8/30/2017 6:40:58 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow