0

Example in the EF6 migration file Up method.

I wish to add a new column B in existing table Country.

Sql("ALTER TABLE [dbo].[Country]
     ADD [B] INT DEFAULT((0)) NOT NULL;")

Then I will need to add this new column B to it's VCountry view and I did the following:

DropView("VCountry")

Sql("CREATE VIEW [dbo].[VCountry]
         AS
         SELECT A, B FROM Country")

Everything looks good until I run the Add-Migration XXX command and the Invalid column name 'B'. prompt out.

What I trying to figure out is how to add the new column to the table and it's relevant view at the same migration file?

Any help would be much appreciated!

1 Answer 1

0

I have tried your method and it's working on my computer. Have you checked the column name having wrong spelling?

1
  • Sorry my bad, you are right!
    – Khai Kiong
    Commented Jul 26, 2019 at 7:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.