0

recently I have been trying to connect to the existing database in Oracle. I code in C# on Visual Studio Community 2019 and wanted to do it through Entity Framework. I found out that the first thing to do is to download Oracle.EntityFrameworkCore through NuGet packages, but encountered an error.

I work on the console application for .NET Framework. The error is in Polish, my native language, but in English it should state

You can't install package "Oracle.EntityFramework.Core 6.21.5". You are trying to install it in the project which targetting ".NETFramework,Version=v4.7.2", but the package doesn't contain any references or files compatible with this structure. For more info contact the author of the package."

Does someone know what I can do?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kiks455
  • 33
  • 6
  • 2
    Short answer: NETFramework,Version=v4.7.2 is not .NET Core. – Robert Harvey Feb 21 '22 at 16:16
  • Try [this package](https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/) instead, or switch to .NET Core. – Robert Harvey Feb 21 '22 at 16:17
  • I managed to download that package. I am going to look for a way to check if I can connect correctly to my database now, but if you have a quick way to check that I would be grateful if you told me. – Kiks455 Feb 21 '22 at 16:39
  • https://stackoverflow.com/questions/19211082 – Robert Harvey Feb 21 '22 at 16:44
  • Specifically, this answer: https://stackoverflow.com/a/28916585 – Robert Harvey Feb 21 '22 at 16:45
  • I don't think it works, at least it doesn't work with the ways I can check. I tried to add an connection through Project->Add->ADO.NET Entity Data Model->New Connection, but Oracle doesn't pop up as a data source. I also tried making a Context class by myself and overriding an OnConfiguring function, but it doesn't recognize DbContextOptionBuilder, I think it needs Microsoft.EntityFrameworkCore and I can't install that because of pretty much the same error as above. – Kiks455 Feb 21 '22 at 16:51
  • Ok, I didn't see your answer, I will look into that – Kiks455 Feb 21 '22 at 16:52
  • The function doesn't return anything, not false nor true – Kiks455 Feb 21 '22 at 16:58
  • Check your connection string. – Robert Harvey Feb 21 '22 at 16:58
  • Hovewer, that is probably right as I couldn't override the OnConfiguring function or something. In short, there is no connection string in the context class, I just tried to connect it in other ways so I imaging that the code solution would't connect by itself – Kiks455 Feb 21 '22 at 17:00
  • What did you mean by switching to .Net Core? Did you mean creating a .Net Core application in Visual Studio? – Kiks455 Feb 21 '22 at 17:03
  • Yes, that's what I meant. – Robert Harvey Feb 21 '22 at 17:04
  • The Oracle docs are [here](https://docs.oracle.com/cd/E56485_01/win.121/e55744/toc.htm), if you're so inclined. It looks like these cover Entity Framework 6 under .NET Framework (not .NET Core). – Robert Harvey Feb 21 '22 at 17:08
  • Ok, I created an ASP.NET Core application and tried to download Oracle.EntityFrameworkCore again but this time I got this error - ,,Package ,,Oracle.EntityFrameworkCore 6.21.5" is not compatible with .net5.0(.NETCoreApp,Version=v5.0). Package ... works with .net6.0". I tried to change the .NetCore verion in the project properties, but the 5.0 version was the latest one – Kiks455 Feb 21 '22 at 17:11
  • You can find .NET 6.0 [here](https://dotnet.microsoft.com/en-us/download/dotnet). Don't be surprised if it asks you to use Visual Studio 2022. – Robert Harvey Feb 21 '22 at 17:13
  • From [here](https://devblogs.microsoft.com/dotnet/announcing-net-6): *"NET 6 is supported with Visual Studio 2022 and Visual Studio 2022 for Mac. **It is not supported with Visual Studio 2019.** If you want to use .NET 6, you will need to upgrade to Visual Studio 2022"* – Robert Harvey Feb 21 '22 at 17:17
  • Yeah, N/A for 2019 – Kiks455 Feb 21 '22 at 17:19
  • I will download it and see if it helps – Kiks455 Feb 21 '22 at 17:22
  • In the meantime, just so we are on the same page, the problem with the error I created this question for is that .NET Framework is not compatible with whataver with the suffix Core? – Kiks455 Feb 21 '22 at 17:25
  • Correct. ....... – Robert Harvey Feb 21 '22 at 17:46
  • Ok, I am able to install the package now, thank you for your help – Kiks455 Feb 21 '22 at 17:52
  • Hi, glad to know you've found the solution to resolve this issue! You can invite Robert Harvey to write an answer, or answer the question by yourself.It will also help others to solve the similar issue. – Jingmiao Xu-MSFT Feb 25 '22 at 05:05

0 Answers0