I have a completed asp.net core 3.1 app created by VS 2019 named BulkyBook. It contains the main app layer (BulkyBook), DataAccess layer, Models layer and utility layer. It was a code first app. I copied the project without any changes to my local host server (Ubuntu 20.04 on VMware work station and MariaDB as database). I could run the app on server successfully :
1- Go to project directory (contains BulkyBook.
csproj
)2-Run
dotnet tool install --global dotnet-ef
3- Restart the server
4-Run
dotnet ef update database
5- My data base and tables builded :)
Now, I published my app to a folder as below (using Vs 2019 on windows):
Publish method : File System
Target Framework : netcoreapp3.1
Target Runtime : Linux-x64
Now I have a published folder having no .csproj
file !!
When I copy it to my local server I do the same again:
1- Delete the database created recently
2- Go to published directory (my app directory with lots of .dll and wwwroot folder and ... but no .
csproj
file)3- Run
dotnet ef update database
But now the following error appeard:
No project was found. Change the current working directory or use the --project option.
I do not know how to publish my project to include .csproj file or maybe something else that is required for update database
Maybe good to say that I can run my published app in this directory with dotnet BulkyBook.dll
, though in the browser showing an error of Unknown database/Apply migrations
This is my BulkyBook.csproj file in VS 2019 : (BulkyBook is main layer/ Application layer)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>aspnet-BulkyBook-3AD31971---B2E8-</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference
Include="EntityFrameworkProfiler" Version="5.0.5044" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.3" />
<PackageReference
Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
<PackageReference
Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
<PackageReference
Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.2" />
<PackageReference
Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.3" />
<PackageReference
Include="Microsoft.Extensions.Logging" Version="3.1.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BulkyBook.DataAccess\BulkyBook.DataAccess.csproj" />
<ProjectReference Include="..\BulkyBook.Models\BulkyBook.Models.csproj" />
<ProjectReference Include="..\BulkyBook.Utility\BulkyBook.Utility.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\images\product\" />
</ItemGroup>
</Project>