Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment out FillinDatabase(); in program.cs before add-migration #49

Open
ddepassUSOM opened this issue Jun 27, 2024 · 3 comments
Open
Assignees

Comments

@ddepassUSOM
Copy link

ddepassUSOM commented Jun 27, 2024

error
To get the project to work I had to do the following:
BEFORE EXECUTING -->

"Inside Package Manager Console :
Select DBAccess inside Default project picklist
Execute the command :
Add-Migration CreateInitialDatabase -Context MsSqlDbContext for Microsoft SQL Server
Add-Migration CreateInitialDatabase -Context PostgreSqlDbContext for PostgreSQL"

One would need to got to program.cs and comment out await FillInDatabase(); Line 81

Then run in my case - >Add-Migration CreateInitialDatabase -Context MsSqlDbContext
Then run in my case -> Update-Database -Context MsSqlDbContext

After Database is created then go back to Program.cs uncomment await FillInDatabase(); Line 81

Then run the startup project BlogCoreAPI
This will now initiate DbInitializer to pre-populate the database. Swagger will work fine.
So, there is nothing wrong with the code it's, awesome. Just update the wiki.
Thank you for your effort with this.
Do you have an example web application using this API?
Please
Thank you
Dwight

@VianneyDoleans
Copy link
Owner

Thank you for the feedback, I will have a look about it and make some quick changes, probably this week-end, Getting Started part should not be a problem.

Unfortunately no there is currently no other example than the swagger interface. I'm thinking of doing a front in blazor or something like that one day but for the moment there's no integration.

@VianneyDoleans
Copy link
Owner

@ddepassUSOM
I didn't encounter any problems when I followed these steps to try and reproduce the problem :

  • Clone the repository
  • Open project and edit appsettings.json to
    "DatabaseProvider": "MsSQL",
       "ConnectionStrings": {
       "Default": "Server=.;Database=AnyRandomName;Integrated Security=True;TrustServerCertificate=True"
      }
    
  • Open Package Manager Console
  • Select DBAccess as default project
  • Execute Add-Migration CreateInitialDatabase -Context MsSqlDbContext
  • Execute Update-Database -Context MsSqlDbContext
  • Run the project

Why did you need to comment await FillInDatabase(); before executing the Entity framework migration commands ? this method normally has no influence on these commands.

Could you give some more details so I can better understand the problem ?
thank you in advance.

@VianneyDoleans VianneyDoleans self-assigned this Jul 21, 2024
@ddepassUSOM
Copy link
Author

ddepassUSOM commented Jul 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants