C
C#2y ago
yatta

❔ What could possibly be the reason when I run database -update but no tabled added ?

Pretty much as the title says, I run the command as in the image wanting to update my new created entity into my database, but when I check the database, there's no new table added, can someone help me what could possibly go wrong here ?
9 Replies
undisputed world champions
did you Add-Migration before? this should add a migration with all the changes since the last migration was created after that you can Update-Database to apply the new migration to the database (creating the new table)
yatta
yattaOP2y ago
i did, I have this migration
undisputed world champions
that doesn't look right (the methods should have code in them) did you add a DbSet<...> for your new type to your dbcontext?
yatta
yattaOP2y ago
im not sure I've made any action on my dbcontext, I'll check it then
trunksvn
trunksvn2y ago
you should have something like this in ur class "nameDBContext"
trunksvn
trunksvn2y ago
Then you override the method OnModelCreating(ModelBuilder modelBuidler) and configure each table with each property definitions
trunksvn
trunksvn2y ago
in my case i do this:
trunksvn
trunksvn2y ago
up to you how should it look
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?