0

I was learning ASP.NET Core MVC through Microsoft Learn and I'm having this problem with adding a new field to an ASP.NET Core MVC app. I first added a new column in the SQL Server table through the designer (dbo.Table [Design]) and then updated it (Shift+Alt+U) and made changes in my model and views.

In my SQL Server Object Explorer, the new column wasn't showing up, so then I tried to update the database through Package Manager Console

Update-Database 

and I get this error:

Error Number:15248,State:1,Class:11
Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.

this is how it looks like

I'm stuck here and nothing's working. I even tried dropping the column and then again tried adding it but still no luck as on updating it showing the same error. Please suggest how to resolve this error.

4
  • 1
    How about add new property in the movie model ? Then add migration and update database again . Commented Oct 13, 2023 at 6:37
  • Does this answer your question? How to update the model when using database first approach Commented Oct 13, 2023 at 6:38
  • From what I see, you are using the Database-first approach. You should scaffold the dbcontext but not update-database as update-database is for code-first approach, which you are add/change/delete table/column through code, generate the migration and update to the database. Commented Oct 13, 2023 at 6:40
  • 1
    @QingGuo yea I tried what you suggested, I deleted the old migration, added a new migration and updated the database. Thanks a lot, it worked. Commented Oct 16, 2023 at 13:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.