Version conflict occur in Microsoft.Entity.FrameworkCore - asp.net-core

I am working on a .net core web application with razor pages.
My application structure is like :
DemoCoreApplication with class Libraries "BLL.Data" and "BLL".
In BLL.Data, I have made the DB context then I have added the reference of "BLL. Data" project into my main project i.e: DemoCoreApplication.
Refrences in BLL.Data class library:
After building the main project (DemoCoreApplication), I got some strange version conflicting errors.

I believe the following steps will solve your problem
Install .Net Core 2.2 SDK (if you don't have)
Convert all projects in the solution to use .Net Core 2.2
Rebuild, Start the project

Related

.Net Core Project Referencing .Net Frameork Projects Problems?

I have a question about .net Core project.
I have a .Net Core Project referencing other projects.
The problem is that a few projects show the warning saying that "Package 'XXXXX' was restored using .NetFramework, Version=v4.6.1.... instead of targer framework .NetCoreApp".
What kind of problems could I have?
Also can I deploy this in Linux for instance and still working fine?
warning showed
Thanks guys
Look at this thread - For a .Net Core 2.1 project, Why does Nuget restores .Net 4.6.1 packages?
What it basically means is the package you have loaded not suitable for .NET CORE, and was restored using a different version of .Net Framework.
Check if the package exists for .NET CORE (search thru NuGet Manager)
Regarding whether it will work on Linux or not - it depends on the package dependencies (e.g. if it is depending on WinForm for example, it probably won't work on Linux).
Even if it will work, I suggest finding a package suitable for .NET CORE.

Can build and run on Visual Studio but cannot Publish

I am having a weird situation where I cannot publish my final Web project. Here is the project structure:
Foo.Services.Common: this is shared library: .NET Standard 2.0.3, Microsoft.AspNetCore.Mvc.Core 2.1.0 with the class DefaultWebSettings defined.
Foo.Services.Common.Razor: Razor Class Library, has reference back to Foo.Services.Common and uses DefaultWebSettings: NETStandard.Library 2.0.3, Microsoft.AspNetCore.Mvc 2.1.0 and some other ASP.NET Core related package (static files, Configuration)
Foo.Services.Api: ASP.NET Core API only (no View, no Razor), has reference back to Foo.Services.Common. Publish well. Uses: Microsoft.AspNetCore.App 2.1.0, Microsoft.NETCore.App 2.1.0.
Foo.Services.Web: front end project. This one is the one I cannot publish! This one has references to both Common projects. Uses: Microsoft.AspNetCore.App 2.1.0, Microsoft.NETCore.App 2.1.0
However, upon publish, this one shows up:
The type or namespace name 'DefaultWebSettings' could not be found
(are you missing a using directive or an assembly reference?)
The error location is in a file of Foo.Services.Common.Razor project, NOT the Web project.
Funnily, Visual Studio perfectly works even with IntelliSense and Go to Definition:
I can build in both Debug/Release mode, run with/without debug any project in the solution well. Moreover, publishing Foo.Services.Common.Razor works without any problem!
In short: I cannot publish my Web project and have no idea what is the problem. I have tried:
Clean/Build.
Delete/Re-add references.
Manually delete all obj and bin folders.
Please show me what I may missing.
In the end, I had to remove Reference of the Common from Common.Razor and Web projects. I guess they could not build because of some conflict between .NET Standard and .NET Core. Had to copy all code of Common into Common.Razor.

Errors after updating .NET Core MVC template's Nuget packages

I am trying to build a .NET Core application. For this purpose I create a new MVC project from the template ASP.NET Core Web Application (.NET Core).
Once I do this, I inevitably need to install some NuGet packages, and see that there are 26 updates available for my project. So I hit "update all" and get into a big mess. One was having to manually edit the project.json to make the .NETCore.App an object with {"version":"2.0.0","type":"platform"}. Now in the project.json most of the stuff is at version 2.0.0 but I get all these error messages in the Error List, and all of them say pretty much the same thing: The dependency Microsoft.AspNetCore.Authentication.Cookies 2.0.0 does not support framework .NETCoreApp,Version=v1.0
What is my missing step?
Answer came in form of comment:
VS2015 is no longer supported for .Net Core projects. You need to upgrade and migrate your project.json to .csproj too. – DavidG

Duplicated linked item found in the project xxxx bundleconfig.json

I am installing a NuGet Package built from an ASP.NET Core 1.1 class library (embedded view components) into my ASP.NET Core 1.1 web application.
Today the application does not want to load in the project in VS.2017 and giving me this error on the web application project (where I included the NUPKG):
Duplicate linked item found in the project "C:\Users\NAME\.nuget\packages\mypackagetitle\0.0.3\contentFiles\any\netcoreapp1.1\bundleconfig.json
I am puzzled... When I think of it, I do NOT want a bundleconfig.json to be packaged into the NUGET, I only want it to be used for bundlying and minifying the class library prior to building the NUPKG but I do NOT want it included in the NUPKG. I am beginning to think the problem is that because when I look in that folder mentioned above I see bundleconfig.json as part of the included package in both the content\ and contentFiles\ but should be in none of them.

asp.net core project occurs MissingMethodException

I create a new project with ASP.NET Core Web Application(.NET Core).
And it can work after building and running it.
I create a class library with .NET Core and move the files under Service folder in the web project to the library, then add the reference and change namespace in the controllers.
It occurs MissingMethodException after registering a new user.
Asp.net core project seems not able to use class library outside the web project.
The detailed message is as the below.
In ASP.NET Core , everything is in form of nuget packages, hence you might have to create nuget package from the class library and then add it to the current solution.
Hope this information helps.