neozhu / CleanArchitectureWithBlazorServer

This is a repository for creating a Blazor Server dashboard application following the principles of Clean Architecture
https://architecture.blazorserver.com/
MIT License
827 stars 223 forks source link

Adding additional tables #700

Closed buda56 closed 3 months ago

buda56 commented 3 months ago

Hi, Tried adding an additional table to the project, I am having issues trying to add a migration. Can you please advise the steps to add additional tables to the project database.

I created the new class in Domain\Entities folder and added the DBSet entry to the ApplicationDBContext, then tried adding the migration via the ConnectedServices in the Server.UI project.

Regards Peter

neozhu commented 3 months ago

Sure, I will take some time to write documentation on how to add a entity class -> migration table

buda56 commented 3 months ago

Hi, Did some more testing on this, the issue is with the new VS2022 tool that allows migrations form the connected services feature of the Server.UI project. I had set the "Default Project" in the Package Manager Console to "srs\Migrators\Migrators.MSSQL" before running the migration option (see screen shot)

devenv_Ydi0Cg0TmX

I tried running the migration option and got the following error...

devenv_YAuw5tUhU4

I subsequently ran the migration from the Package Manager console (successfully)

devenv_u50Cqc3LAt

Regards Peter

neozhu commented 3 months ago
image
  1. first set default startup project : server.UI project
  2. second select default project: src\Migrators\Database in PMC
  3. last run add-migration cmd
buda56 commented 3 months ago

Yes that is how I got it to work using the PMC, but if you try it using the Connected Services option it fails with the error described above.

devenv_HfYFiqOI4f

Regards Peter

neozhu commented 3 months ago

https://www.youtube.com/watch?v=X1b4hFLs4vo