dotnet ef database update not working - asp.net-mvc

I cant update my identity database with dotnet ef database update. I get no errors but the database is not updated.
I've created a migration with dotnet ef migrations add TerminalIdand it seems to work fine since I now have 20170522123744_TerminalId.cs and 20170522123744_TerminalId.Designer.cs in the migrations-folder. If I do dotnet ef migrations list I get nothing though.
Here's my csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentEmail.Mailgun" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.0.0-*</Version>
</DotNetCliToolReference>
</ItemGroup>
</Project>

Related

Specflow test project fails build .NET 5 windows7

I get this error building my specflow test project
I cannot figure out why I get these compile bugs..
I am quite sure it has to do with use .NET 5,
don't have a lib folder, where the libraries/nugets are stored...
my project looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="FluentAssertions" Version="6.7.0" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<Folder Include="Drivers\" />
<Folder Include="Hooks\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MagVenture.Utilities.UI\MagVenture.Utilities.UI.csproj" />
</ItemGroup>
I cannot figure it out... - there is a twirl somewhere that I didn't see..
Disable the NU5100 warning, when treating warnings as errors.
it is due to the .NET framework versions policies about location in lib folder.

Error NU1605: Docker restore nuget packages failed

I am running my .netcore3.1 microservices into docker, for this I have added docker(window based) file into service.
When I run microservice with docker its throw error on step 'determining projects to restore...'
error
warning NU1603: Team.Api depends on ExceptionHandler (>= 1.0.0-CI-20200424-092531) but ExceptionHandler 1.0.0-CI-20200424-092531 was not found. An approximate best match of ExceptionHandler 1.0.0 was resolved.
1>/src/TeamApi/Team.Api.csproj : warning NU1603: Team.Api depends on MessageBroker (>= 1.0.0-CI-20200923-130139) but MessageBroker 1.0.0-CI-20200923-130139 was not found. An approximate best match of MessageBroker 1.0.0 was resolved.
1>/src/TeamApi/Team.Api.csproj : error NU1101: Unable to find package MessageBrokerRabbitMQ. No packages exist with this id in source(s): nuget.org
1>/src/TeamApi/Team.Api.csproj : warning NU1701: Package 'ExceptionHandler 1.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.
1>/src/TeamApi/Team.Api.csproj : error NU1605: Team.Api -> MessageBroker 1.0.0 -> Microsoft.Extensions.Hosting 3.1.3 -> Microsoft.Extensions.Logging.Debug (>= 3.1.3)
1>/src/TeamApi/Team.Api.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.Logging.Debug from 3.1.3 to 3.1.1. Reference the package directly from the project to select a different version.
1>/src/TeamApi/Team.Api.csproj : error NU1605: Team.Api -> Microsoft.Extensions.Logging.Debug (>= 3.1.1)
1> Failed to restore /src/TeamApi/Team.Api.csproj (in 52.24 sec).
docker throw error on randomly package on every build
Docker specs which I am using are:
Windows version: 1903 (18362.418)
Docker Desktiop version: 3.1.0 (51484)
Engine: 20.10.2
Docker file created by Visual Studio 2019
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["TeamApi/Team.Api.csproj", "TeamApi/"]
RUN dotnet restore "TeamApi/Team.Api.csproj"
COPY . .
WORKDIR "/src/TeamApi"
RUN dotnet build "Team.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Team.Api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Team.Api.dll"]
I have created docker file for Linux as well but the result is same
Update1: Project's .csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
<UserSecretsId>1d75b031-5ef6-420a-9f88-5b2bb3b78187</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Infrastructure\20200116074051_TeamDB.cs" />
<Compile Remove="Infrastructure\20200116074051_TeamDB.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200116102750_CompanyID.cs" />
<Compile Remove="Infrastructure\Migrations\20200116102750_CompanyID.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200116103510_CompanyIDcccc.cs" />
<Compile Remove="Infrastructure\Migrations\20200116103510_CompanyIDcccc.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200116110757_UserTable.cs" />
<Compile Remove="Infrastructure\Migrations\20200116110757_UserTable.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200116111728_UserTable.cs" />
<Compile Remove="Infrastructure\Migrations\20200116111728_UserTable.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200120064812_new.cs" />
<Compile Remove="Infrastructure\Migrations\20200120064812_new.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200120065302_UpdateUser.cs" />
<Compile Remove="Infrastructure\Migrations\20200120065302_UpdateUser.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200120065757_UpdateUser.cs" />
<Compile Remove="Infrastructure\Migrations\20200120065757_UpdateUser.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200120065948_UpdateUser.cs" />
<Compile Remove="Infrastructure\Migrations\20200120065948_UpdateUser.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200122052759_CompanyUpdate.cs" />
<Compile Remove="Infrastructure\Migrations\20200122052759_CompanyUpdate.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200122063655_UpdateCompanyAndUser.cs" />
<Compile Remove="Infrastructure\Migrations\20200122063655_UpdateCompanyAndUser.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200122064700_UpdateCompany.cs" />
<Compile Remove="Infrastructure\Migrations\20200122064700_UpdateCompany.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200122102506_Updated.cs" />
<Compile Remove="Infrastructure\Migrations\20200122102506_Updated.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200123051214_TeamDB.cs" />
<Compile Remove="Infrastructure\Migrations\20200123051214_TeamDB.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200123133951_CompanyRelation.cs" />
<Compile Remove="Infrastructure\Migrations\20200123133951_CompanyRelation.Designer.cs" />
<Compile Remove="Infrastructure\Migrations\20200123134744_CompanyRelationUpdate.cs" />
<Compile Remove="Infrastructure\Migrations\20200123134744_CompanyRelationUpdate.Designer.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.10.0" />
<PackageReference Include="ExceptionHandler" Version="1.0.0-CI-20200424-092531" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" />
<PackageReference Include="HangFire.Core" Version="1.7.11" />
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
<PackageReference Include="HangFire.SqlServer" Version="1.7.11" />
<PackageReference Include="MessageBroker" version="1.0.0-CI-20200923-130139"/>
<PackageReference Include="MessageBrokerRabbitMQ" version="1.0.0-CI-20200923-130139"/>
<PackageReference Include="linqtotwitter" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.6" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.2.5" />
<!--<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>-->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="EntityFramework" Version="6.4.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0" />
<PackageReference Include="Polly" Version="7.2.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.39" />
</ItemGroup>
<!--<ItemGroup>
<ProjectReference Include="..\MessageBrokerRabbitMQ\MessageBrokerRabbitMQ.csproj" />
<ProjectReference Include="..\MessageBroker\MessageBroker.csproj" />
</ItemGroup>-->
</Project>
Update2
The RINFeed NuGet Source is missing from your container NuGet config, this source exist in one of your NuGet config hierarchy
You have two choice:
Create a nuget.config (or use the existing with RINFeed) and copy it to the container
COPY "nuget.config" .
Run a command into the container to add the source
dotnet nuget add source ....
See this stackoverflow question as a guide.
Warning
The URL in the RINFeed must be resolved by DNS container

Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly

I am trying to install an existing project in Dotnet core but I was getting the error
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<StartupObject></StartupObject>
<!--<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Boilerplate.AspNetCore" Version="3.0.0" />
<PackageReference Include="BuildBundlerMinifier" Version="2.8.391" />
<PackageReference Include="Captcha" Version="4.4.2" />
<PackageReference Include="linqtotwitter" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.2.1" />
</ItemGroup>
Try to update these from the NuGet Package Manager will fix your issue
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers

dotnet publish compiles Microsoft.AspNetCore.JsonPatch.dll with wrong version

I have an interesting problem. When I use dotnet publis on my desktop PC it compile my project without errors on Linux run. When I compile the same project on my laptop there are one error on the Linux run, that complaining on Microsoft.AspNetCore.JsonPatch. As I tried to figure out what is wrong, I found out that dotnet publis on my laptop uses v2.2, if I build my solution from VS2019 it uses the correct version of 3.0 (my project is .net core 3).
interesting is that on my laptop i got generated web.config file with the following content
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\portalnekretnine.com" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: F1180308-B6BA-4CCE-A131-F48B9B2DFD5E-->
any ideas?
here is how am I building from command line
dotnet publish D:\Projects\PortalNekretnine\Backend\PortalNekretnine.sln --configuration Release --framework netcoreapp3.0 --output .\build\ --self-contained false --runtime linux-x64 --verbosity quiet
My API's csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>portalnekretnine.com</AssemblyName>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
<PackageReference Include="IdentityModel" Version="4.0.0" />
<PackageReference Include="IdentityServer4" Version="3.0.1" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Analyzers" Version="3.0.0-preview3-19153-02" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.1.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NSwag.Core" Version="13.1.3" />
<PackageReference Include="Serilog" Version="2.9.0-dev-01133" />
<PackageReference Include="Serilog.Exceptions" Version="5.3.1" />
<PackageReference Include="Serilog.Settings.AppSettings" Version="2.2.2" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0-dev-00850" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="5.0.0-rc8" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0-rc4" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\portalnekretnine.infrastructures\portalnekretnine.infrastructures.csproj" />
<ProjectReference Include="..\portalnekretnine.models\portalnekretnine.models.csproj" />
<ProjectReference Include="..\portalnekretnine.services\portalnekretnine.services.csproj" />
</ItemGroup>
</Project>
if any code sample or configuration needed, pls let me know.
thnx

.NET Core F# project will not write to TraceSource

I could not get my F# project to write to the TraceSource.
Here was my F# code:
use logFileStream = new FileStream("log.txt", FileMode.Append, FileAccess.Write)
(
use logFileListener = new TextWriterTraceListener(logFileStream)
(
let traceSource = TraceSource("Test", SourceLevels.All)
traceSource.Listeners.Add(logFileListener) |> ignore
traceSource.TraceEvent(TraceEventType.Verbose, 1, "This is a test.")
)
)
Here was my F# project:
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
<PackageReference Include="System.Diagnostics.TextWriterTraceListener" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
</ItemGroup>
</Project>
Why was log.txt empty?
I needed to add <DefineConstants>TRACE</DefineConstants> to a PropertyGroup within my project file.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>

Resources