wanted to check my EF version number - Properties says 6.0.0.0, so I used the PM console to Install-Package EntityFramework & it (the PM Console) reports EntityFramework 6.1.2 already installed.
I'm using .Net framework 4.5 so I'm expecting no problems. Does EF in fact report the most current version under properties, or does it always say 6.0.0.0? Any advice?
Look at the file properties of EntityFramework.dll in Windows Explorer, and you will see a product version of 6.1.2 - the 6.0.0.0 version is the assembly version
Related
I am following this tutorial:
https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=visual-studio
I am immediately stopped because I can not complete the following command:
Install-Package Microsoft.EntityFrameworkCore.Sqlite
This is the error:
Could not install package 'Microsoft.EntityFrameworkCore.Sqlite.Core 7.0.0'. You are trying to install a 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. For more information, contact the package author.
I am attempting to learn how to use the Entity Framework and so I don't know much regarding this. Any advice would be helpful even if it's a link to something I need to read.
About the tutorial
The tutorial is about .netCore but in the error message you can see that you created a .netFramework project '.NETFramework,Version=v4.7.2'.
Create a new console application, but don't select projects that have (.NET Framework) in the description.
About the Sqlite package (only if continue the practicing with .netFramework)
The command Install-Package Microsoft.EntityFrameworkCore.Sqlite will try to install the last version. Currently, the last version is 7.0.0. This version only work with .NET 6.0.
You can check existing .net versions right here
So, you need to specify the version. The version for .NET 4.7.2 is the 3.1.31.
Install-Package Microsoft.EntityFrameworkCore.Sqlite -Version 3.1.31
Nuget Sqlite package info here
I have installed Visual Code 2022 preview (17.1). I have created a simple console app following https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli
When I try to add a migration I get the following error
> dotnet ef migrations add One
Build started...
Build succeeded.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.
- The following frameworks were found:
5.0.8 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=win10-x64
Why would it want dot net 2.0?
Add the package Microsoft.EntityFrameworkCore.Design to your main project. if that doesn't work, add to your Data Access layer (project).
I have a C# .NET Core 3.1 console application. I need to query a SQL database via stored procedures for data retrieval.
I've been trying to use NuGet to install Microsoft.EntityFrameworkCore packages into the projects.
I get errors saying that Entity Framework Core 5.0 is not compatible with .Net Core 3.1. I've tried earlier versions of Entity Framework Core, but I still get compatibility errors.
Should I be trying to use Entity Framework Core with .NET Core? Is there a way around these compatibility issues?
How do I call SQL stored procedures from EF Core?
Here are the errors I'm seeing when I try to add EntityFrameworkCore.SQL package to my solution via NuGet:
Error Package restore failed. Rolling back package changes for 'Foo.WebAPI'.
Error NU1202 Package Microsoft.Extensions.DependencyInjection 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.DependencyInjection 5.0.0 does not support any target frameworks.
Error NU1202 Package Microsoft.IdentityModel.Tokens 5.6.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.IdentityModel.Tokens 5.6.0 does not support any target frameworks.
Error NU1202 Package System.Net.NameResolution 4.3.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package System.Net.NameResolution 4.3.0 supports: - monoandroid10 (MonoAndroid,Version=v1.0) - monotouch10 (MonoTouch,Version=v1.0) - xamarinios10 (Xamarin.iOS,Version=v1.0) - xamarinmac20 (Xamarin.Mac,Version=v2.0) - xamarintvos10 (Xamarin.TVOS,Version=v1.0) - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0)
Hopefully you were able to get around the install issues you were having with .net core 3.1->5.0 upgrade. One approach there might be to just start over with a new .net core console app targeted to core 5.0 and move all your buisness logic, etc into the new console app. If you did get through the upgrade issues, here's an answer to your question above.
var user = "johndoe";
var blogs = context.Blogs
.FromSqlRaw("EXECUTE dbo.GetMostPopularBlogsForUser {0}", user)
.ToList();
from Microsoft Docs "Raw Queries" https://learn.microsoft.com/en-us/ef/core/querying/raw-sql
Personally I try to avoic using SP's in code first EF like the plauge, but there are rare occasions where LINQ and EF cant handle the job and you have to goto SP's.
EdmGen.exe is not supporting targetversion 4.7.2.
Exception thrown as "error 7025: Only .NET Framework version 4 and 4.5 are supported. To use another version use the tools that shipped with that version."
To the best of my knowledge there is latest version of EdmGen.exe. Is there any way that I can generate edmx with target .net framework version 4.7.2 ...?
I have tried EF 4.1.10715 and EF 4.1.10331.0 both packages seem to target Framework 3.5, but have dependencies on mscorlib, Version 4.0.0.0
Below is screenshot of Package Config for Version 4.1.10331.0 from this morning.
At compilation, we fail with
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3258: The primary reference "EntityFramework" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
Any ideas?
After created a new WinForm project in Visual Studio 2012 with .NET 3.5 as the target framework, I installed the 4.1.10715.0 version of Entity Framework and had the same issues.
Opening the referenced EntityFramework assembly in dotPeek confirms that it was compiled for .NET 4.0.
Despite the targetFramework indicated 3.5 in packages.config, the referenced assembly has been compiled for .NET 4.0.
<packages>
<package id="EntityFramework" version="4.1.10715.0" targetFramework="net35" /></packages>
Looks like someone mishandled a package prior to publishing.
EntityFramework 4.0+ (including 4.1) do not support .NET Framework 3.5. The only version you can use on a .NET Framework 3.5 is EF1 which is part of the .NET Framework 3.5 SP1. So, if you don't have the SP1 version you won't be able to use EF at all.