Can I use Microsoft.EntityFrameworkCore in a standard .NetFramework solution in Visual Studio 2019? - entity-framework-core

Does Microsoft EntityFrameworkCore work with standard .Net Framework applications?
I read a couple posts which said it was possible to.
However, when attempting to install via NuGet Package Manager, I get the following error message:
Could not install package "Microsoft.EntityFrameworkCore.Design
5.0.0". You are trying to install this package into a project that targets ".NetFramework, Version=v4.7.2', but the package does not
contain any assembly references or content files that are compatible
with that framework.
Is there something I'm doing wrong, or is EntityFrameworkCore not intended for use with standard .NetFramework applications?

Sorry, I have to correct my answer, I was wrong. EF Core 3.1 can be used with .NET Framework 4.7.2 or later.

EF Core 5.0 cannot be used with .NET Framework 4.7.2
see https://learn.microsoft.com/en-ca/ef/core/miscellaneous/platforms
I also tried it before and got the same error message described above

Related

Why does NuGet package reference incorrect .NET framework/standard?

tl;dr:
I have a .NET Framework 4.7.2 project consuming a NuGet package which supports .NET Standard 2.0. That package, in turn, requires another package which supports .NET Standard 2.0. However, when run, the latter package uses net461 binaries rather than netstandard2.0.
How do I force a NuGet package & its dependencies to use .NET Standard 2.0?
Are there special steps required to consume a .NET Standard package from a .NET Framework 4.7.2 project?
Specifics:
I am trying to get the NuGet package for SparkplugNet (which uses the MQTTNet package) working in a .NET Framework 4.7.2 project - just the basic "How to use" SparkplugB example. Both projects support .NET Standard 2.0. After some debugging (details below), it appears MQTTNet is trying to use code paths specific to .NET Framework 4.6.1, rather than .NET Standard 2.0, and crashing with no feedback whatsoever.
To troubleshoot, I built SparkplugNet and MQTTNet from source. As far as I can tell, the crash comes from hitting .NET 4.5/4.6.1-specific code in CrossPlatformSocket.ConnectAsync(), specifically this line (in context):
await Task.Factory.FromAsync(_socket.BeginConnect, _socket.EndConnect, host, port, null).ConfigureAwait(false)
When I debug, _socket is a System.Net.Sockets.Socket which doesn't appears to have a BeginConnect() method, at least in the source file my debugger pulled. I am not sure why it branches to that code when .NET Standard 2.0 would be a better fit.
Back to a 4.7.2 project consuming SparkplugNet & MQTTNet via NuGet package.... If I look at the reference paths, SparkplugNet is properly pointed at the netstandard2.0 folder, but MQTTNet points to packages\MQTTnet.4.1.3.436\lib\net461\MQTTnet.dll. If I change the hint path manually in the project file, MSBuild appears to pull from the netstandard2.0 folder, but it still crashes. I assume it is the same cause, though I'm having trouble debugging using NuGet packages. Also, I'm hoping for a better solution than hacking hint paths.

What are the minimum Nuget packages for running Entity Framework Core 3?

I would like to add Entity Framework 3 to a .Net Core (3.0) WPF desktop app. I am using VS 2019. I think the minimum packages are:
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.Tools
And of course one for the database provider:
Microsoft.EntityFrameworkCore.SqlServer
Did I get this correct? Anything in the list that is not needed? Anything missing?
You may not need Tools and Design, and Core gets installed automatically with the provider package.

Set .NET Framework version for ScriptComponentProject

Is it possible to set the .NET Framework version for a ScriptComponentProject?
Currently it defaults to .NET 4, but I want it to be .NET 4.6.1
I've looked on the documentation page for ScriptComponentProject (https://www.varigence.com/Documentation/Samples/Biml/Script+Component+Project), but without any luck.
Ah, I found the answer! You need to set the Target Framework Version in your script project:
https://www.varigence.com/Documentation/Language/Element/AstComponentScriptProjectNode
And I think the available values are these:
Unspecified
Unspecified .NET Framework Version
NetFX20
.NET Framework 2.0
NetFX30
.NET Framework 3.0
NetFX35
.NET Framework 3.5
NetFX40
.NET Framework 4.0
NetFX45
.NET Framework 4.5
NetFX451
.NET Framework 4.5.1
NetFX452
.NET Framework 4.5.2
NetFX46
.NET Framework 4.6
NetFX461
.NET Framework 4.6.1
Which can be found here: https://www.varigence.com/Documentation/Api/Enum/ScriptProjectTargetFrameworkVersion
If you are using BIMLExpress 5.0.6xxx, you have probably faced the same issue.
I opened the generated .dtsx package and found that the TargetFrameworkVersion node placed inside of a separate PropertyGroup node. After I had moved it out to the first PropertyGroup of the same arrayElement node, then reopened my package in Visual Studio again, issue was gone! So you can write a script to move TargetFrameworkVersion node into the proper place for now.
Varigence support team told me that a public preview release is coming late next week which will include a fix for that (+also VS2017 support!).

how to install Microsoft.Azure.DocumentDB.Core on portable library

I get error installing documentDB nuget package.
Could not install package 'Microsoft.Azure.DocumentDB.Core 1.2.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile7', but the package does not contain any assembly references or content files that are compatible with that framework.
Any ideas? thanks in advance.
The Core package actually targets NetStandard 1.6, not .Net Core specifically.
NetStandard is a library that acts as API for different runtimes and it's much more powerfull than PCL because it's platform-agnostic:
This means that the DocumentDb.Core package can run on .Net Core 1.0, .Net Framework, Xamarin and UWP.
If you are creating a PCL, I would recommend you to create a NetStandard library instead.
It will let your library support a much wider universe of platforms and the great thing is that, if a new platform comes along that supports NetStandard 1.6 (for example), your library will work without needing to recompile or republish it.
This error message tells us that this assembly Microsoft.Azure.DocumentDB.Core is not supported on portable library. From this assembly nuget site, we know that This client library enables client applications targeting .NET Core to connect to the Azure DocumentDB service. If you want to use Azure DocumentDB library, please try to see if this assembly works Install-Package Microsoft.Azure.DocumentDB

C++/CLI and Entity Framework 5

I thought I'd try using EF 5 with C++/CLI in VS2012, so that I could try Code First. The package downloads via NuGet fine, but isn't visible to the solution.
On investigating, the Package Manager says that the package is not compatible with the version of the Framework being used by the solution, and requires 4.0 or 4.5... but the config for the project (a plain Win32 console app) says it is using v4.5.
Has anyone come across this and found a way to fix it?