I am creating a sample EF Core project using SQL Server and deploying it in Azure.
As of now, I have a BookingAPI
service and there are 2 class libraries which are called SharedServices
and Domains
.
BookingAPI
does NOT have an ApplicationDBContext
. The Domains
project has an ApplicationDBContext
and all the domains are also, inside it.
BookingAPI
is calling the Domains
project to access the database.
The project structure looks like this
- BookingServices (Folder)
- BookingAPI (ASP.NET Core Web API)
- Program.cs
- appsettings.json
- appsettings.Development.json
- appsettings.Production.json
- SharedServices (Folder)
- SharedServices (class library)
- Domains (class library)
- Data (Folder)
-ApplicationDBContext
- Migrations (Folder)
- Migration1
- Migration2
- Tables (Folder)
- Bookings.cs
- Tables.cs
As long as I was working in my local, it was completely fine. I could create migrations, and update the database.
But I want to deploy this project to Azure.
For that, I created a database in Azure and also published it from Visual Studio.
However, I am facing the following problems while publishing the BookingAPI
to Azure:
If I add my connection strings in appsettings.Development.json
and appsettings.Production.json
, the Azure publisher can not find them. If I add them to appsettings.json
, then they can be found.
Even if I referenced the Domains
project properly (I am using DbContext
for database update from BookingAPI
), and there are migrations in the Domains
project, these migrations are not found during publish and are not applied to the Azure database.
I am stuck here and can't find any context:
Now after waiting long enough I am getting this error in Publish page
Can anyone help me through this problem ?
Thanks!
The Problem is solved now. The main reason behind this problem was that my project was made in .net core 7 and the azure environment I was installing my service was .net core 8. I had to recreate the projects using .net core 8.