Startup project 'EFGetStartedUWP' is a Universal Windows Platform app. This version of the Entity Framework Core Package Manager Console Tools doesn't support this type of project. For more information on using the EF Core Tools with UWP projects, see https://go.microsoft.com/fwlink/?linkid=858496
I'm trying to connect SQLite Database to a basic UWP app for the sake of learning but when I try migration. It just keep giving me the above error. I've searched quite a lot on the internet but didn't get the appropriate answer. The Microsoft documentation is of no use in this scenario. Also I've installed Microsoft.EntityFrameworkCore.Sqlite & Microsoft.EntityFrameworkCore.Tools.
If anyone can suggest any other way to connect SQLite database to UWP that'll be very useful too as I'm quite new to C# and I've a university project to do on a UWP app.
I've just stepped on a similar issue, and I've been lucky enough to solve it. To start with, I found these links very useful:
Entity Framework Core tools reference - .NET Core CLI - Other target frameworks and Common options.
In my case, my solution ended up with a configuration like this:
the application project (Universal Windows) - startup project for the solution,
a class library project (.NET Standard 2.0) - with the models and context classes,
a dummy console app project (.NET 6.0) - necessary to act like a startup project for the tools.
Have into account that (at the time of writing) UWP doesn't support .NET Standard 2.1. It supports .NET Standard 2.0 from version 10.0.16299. This means the (Universal Windows) application project can't reference a .NET Standard 2.1 project (e.g. .NET 5.0, .NET Core 3.0, Mono 6.4, etc.), so the class library project CAN'T be .NET 2.1, .NET 5.0, etc. The opposite is not true: a .NET 5.0 or .NET 6.0 project can reference a .NET Standard 2.0 project, so the dummy console app project can be .NET 6.0.
Steps to add a migration:
In the class library project, install the Nuget package for the corresponding EFCore platform used (e.g. for SQLite, install Microsoft.EntityFrameworkCore.Sqlite). Do not install the most recent version but the last that depends on .NET Standard 2.0, which is 3.1.21 at the time of writing.
In the dummy console app project, install this Nuget package: Microsoft.EntityFrameworkCore.Design. For compatibility purposes, install the same version as the version chosen in the previous step (e.g. 3.1.21).
In the application project, add a reference to the class library project. (Right-click on the project, select Add > Project Reference..., and tick the class library project.)
In the dummy console app project, add a reference to the class library project. Note there's no need to change anything else in the dummy console app project, although the project doesn't have to be built (less deployed), so feel free to open the Configuration Manager, and untick Build (and Deploy). In addition, in the Configuration Manager, don't bother to change the platform (x64, Any CPU...) to be the same as the referenced class library project. After all, the dummy console app project won't be built, so ignore any warnings about the architecture not being the same as the class library project.
Rebuild your solution to make sure there are no other issues going on. If there are any, fix them before continuing.
Open the command prompt (tip: navigate to the root folder of your solution with Windows File Explorer and type cmd in the address bar to open the command prompt in that folder).
Type the following (-p signals the target project while -s indicates the startup project):
?> dotnet ef migrations add #MigrationName -s #DummyConsoleAppProject -p #ClassLibraryProject
Optionally, unload the dummy console app project, and load it again next time you need it to add a migration.
This looks to be a known issue from here: https://github.com/aspnet/EntityFrameworkCore/issues/9666
Using EFCore with UWP is a bit finicky.
So, add a new project to your solution -> select .net core console app -> create DBContext and your models there -> run the "Add-Migration" command and reference it back to your main project.
That should get rid of that error and let you use migrations with UWP.
Related
I created a .Net 6 class library and now I am trying to create a test project.
a .net 6 test project is not available. Online I found the information to use .Net Framework or .Net core in order to test.
I created a .Net Framework 4.8 test project an referenced my class library.
I receive the Compiler error:
Project '..\CircularList\CircularList.csproj' targets 'net6.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.8'. UnitTests
How do I do Unit tests then? Is there any way to target .Net 6.0 from .Net Framework 4.8?
None of the previous answers worked for me. I was trying to add a Test project for my Windows Forms (.NET 6.0) project. Tried all of the available project templates, and none worked.
Just needed to modify the test project .csproj (by double clicking the Test Project), and change TargetFramework from net6.0 to net6.0-windows.
I guess that must have been the answer. Don't use the project template "Unit Test Project (.NET Framework)" if you want to use test a .net6 library.
Use a more up-to-date template in the project creation wizard. There are newer MSTest ones, but one could also take advantage of better templates like the xUnit one.
I created a NET 6.0 class library and received the same message.
I went into properties, just to double check that my project and my test project were set the same and noticed that the Target OS was not set in my library.
It was in my project, but not in my class library.
Once I changed my class library "Target OS" - to be windows, the same as my project, the error messages went away.
This is A solution, not likely THE only solution:
I also have a .NET 6.0 project that I would like to test.
With the project template picker, I picked the C# NUnit Test for .NET Core. When advancing to next screen, there was a dropdown that allowed me to pick a Target framework. .NET 6.0 was the default option.
None of the previous answers worked for me. In the beginning, I think .Net framework missing, so I install the installer and install, but it doesn't work.
I also try to change the project "Target OS" to "Windows", it doesn't work. I find the Test Project property target is still .Net 4.7.2, the UI is a old version, not like the new version.
Then I remove the Test Project created from the template, and right-click the method to test and click "Create Unit Tests", then create the Test Project by the pop-up window. It works. And the new Test Project works successfully, its property target is .Net 6, and the UI is the new version.
I published my program(.net core 3.1 winform program). but it doesnt excuted even installed .net core 3.1 run-time package. so i install .net core 3.1 sdk package, it works.
why i install sdk instead of run-time package?
The software development kit (SDK) includes everything you need to build and run . NET Core applications, using command line tools and any editor (including Visual Studio). The runtime includes just the resources required to run existing
There was a problem creating a single file by using app.config in the wrong way.
When app.config was used in the correct way, it was confirmed that it works normally only with the runtime sdk.
Previously, both *.dll.config and *.dll were required, but after correcting it, only *.dll.config worked normally.
Will (or does) the DNX project support frameworks other than ASP.net (Such as WPF or windows forms)? I'd love to create some Wpf class libraries using the newer json project style (and native NuGet package support), but everything seems to be geared towards Asp.net.
Dnx is only for ASP.NET 5 projects (web, console or library).
It doesn't support WPF.
The project.json/xproj based project model (I would not call it DNX projects) can indeed be used to build nuget class libraries for scenarios beyond ASP.Net and DNX.
If you specify in your project.json a SDK like net451 you can additionally add frameworkassemblies like "PresentationCore" or "PresentationFramework" and then start coding in class files against WPF. So you can create a class library with it (i just tested it). It builds and packages itself to NuGet. That NuGet you can use then in your normal WPF project.
It is important to understand the concept of a SDK when talking about the new .Net Framework things: DNX is a SDK similar to UWP or the .Net Framework (WPF/WinForm). The SDK then specifies which CLR and BCL are used in combination with the features of the SDK. Consequently, this project format does not target the DNX SDK (from the architecture) but any SDK. In the end a class library is IL which has references to DLLs. Support for direct references with normal .csproj is planned (IMHO).
But there are restrictions: The project format is new, not yet well supported and integrated, there is no and maybe never will be a WPF designer etc.
So i try to develop little andriod application by Xamarin Studio 5.4. I have three projects in my solution - project of android application (ClientProject), some class library that used by first one (MyLib) and some console application (ConsoleApp).
But when i try to add reference to MyLib into ClientProject i fail. Xamarin Studio tells me that "Incompatible target framework .NET Framework Version 4.0".
That looks this
I changed MyLib's framework version to 3.5, to 4.5 but it takes no effect.
But when i try to add this reference into ConsoleApp there is no problem:
So i have to add to ClientProject a reference to MyLib.dll so I can not debug its code.
What should i do to solve this problem?
The Android project will have a framework of MonoAndroid. This framework is incompatible with the full .NET Framework. Your options are to do one of the following:
Create an Android Library Project.
Create a Portable Class Library Project.
Create a Shared Project.
If you are only interested in creating an Android application, and not interested in using the library for other mobile platforms, then the first option will be the simplest.
I have a C# program which I want to make available to my users, but the problem is that it requires .NET framework version 4.0. This is a problem because it was released pretty recently (April 2010) and a lot of people probably don't have it. To make matters worse it takes a while to download and install the framework (~10 minutes).
Is there any way I can install just a part of the framework I need? If that isn't possible can I compile my code down to a native binary for specific systems
eg. x86 32-bit, x86 64-bit, etc.
I've looked at a company called 'spoon' http://spoon.net/ but that looks like it just emulates apps on a server (sort of like citrix). What can I do to resolve this dilemma?
Anyone who wants to run your program needs the appropriate version of the .NET Framework installed. There's no way to work around this. It honestly amazes me how often this question gets asked. You can't compile .NET code down to any kind of a "native binary", and you can't distribute only the portions of the framework that you need. If all of this was important to you, you should have chosen a different development platform in the beginning.
Your only option is to bundle the .NET Framework along with your application's installer. The way to make this easiest on your customers is to use Visual Studio to create a setup project that will automatically install the .NET FW if they don't have it already, and then install your application, all in a single step process.
Visual Studio has built-in support for creating such a setup project, and most of the dirty work is handled for you. File -> New Project -> Other Project Types -> Setup & Deployment -> Visual Studio Installer. Then, pick either the "Setup Project" or "Setup Wizard" option, and follow the instructions.
The only thing to keep in mind since you've developed for .NET 4.0 is that there are two versions of this framework: the full version and the "Client Profile". The Client Profile is an attempt to do exactly as you mention and install only the portions of the framework that are used by the typical application. You have to first figure out of this is a deployment option for you. If your program uses classes that are not available in the Client Profile, you need to install the full version. Otherwise, you can consider installing the Client Profile, which is the default for all new projects targeting .NET 4.0 in VS 2010. Check the "Target Framework" settings for your application, under the project Properties. If it's not set to Client Profile already, try changing it and see if it will compile. That's the quickest way to tell if this deployment option is available to you. But there's only about a 15% difference in size between the two frameworks, so it isn't really that big of a deal if you must deploy the full version.
Either way, the setup project will automatically determine and bundle the correct version for your app. Definitely don't make the user download and run the .NET installer separately. Use the setup project and do this for them automatically. If you don't have VS or don't want to use the one it provides, investigate alternatives, like Inno Setup, which also support deploying and installing the .NET runtime with an app.
In many cases you do not need the entire .NET Framework 4.0 and can use the much smaller .NET Framework Client Profile. You can then use an installer to bundle the client profile installer with your app into a single deployment.
You cannot run a .NET app without the framework. If this is a deployment issue for your customers, you should consider either a Click-Once installer (web-based automated installation and updating) or porting the app to Silverlight.
For the sake of completeness, there is also the possibility for .NET Core release deploy Self-Contained Deployments (SCD) nowadays. When you create a self-contained deployment, .NET Core tools automatically include the latest serviced runtime of the .NET Core version that your application targets.
Deploying a Self-contained deployment has two major advantages:
You have sole control of the version of .NET Core that is deployed with your app. .NET Core can be serviced only by you.
You can be assured that the target system can run your .NET Core app, since you're providing the version of .NET Core that it will run on.
Here is a small guide from Scott Hanselman.