I am starting to learn UWP platform. In first steps I want to do simple application (bookshop). Unfortunately, I got stuck on steps: how to use Entity Framework with SQL Server in UWP?
First I was using
Install-Package Microsoft.EntityFrameworkCore.SqlServer
but I got lots of conflicts (ex. System.Threading.Thread 4.3.0 error, or One or more packages are incompatible with UAP,Version=v10.0 (win10-x86).).
After that, I was trying add a classic dll to project (and install ef), but... classic library are incompatible with UWP...
Do you have any idea how to use EF with SQL Server in UWP ? I don't want to use sqlite...
Sorry you can only use the entity framework SQLite provider with UWP.
The latest version of Windows SDK (Falls Creators Update) will support direct SQL Server connection. Have a look at it here:
https://learn.microsoft.com/en-us/windows/uwp/data-access/sql-server-databases
To use SQLite in your UWP app, you need to target Windows 10 Fall Creators Update (10.0; Build 16299)
The NuGet packages are:
Microsoft.EntityFrameworkCore.Sqlite
Microsoft.EntityFrameworkCore
I successfully connected ms sql, entity framework to uwp.
They work together.
To connect, I used an additional project "csproj" with the standard .NetStandard 2.0 in the same solution. I also used "Microsoft.EntityFrameworkCore.SqlServer" in this project, not in the UWP project. It was just class library
Related
I’ve been recruited onto a project to modify an existing microservice thats’s written in C# and that runs in a Linux env—CentOS flavor. Presently it persists data as JSON in a key-value store. My task is to reimplement the persistence to use PostgreSQL and an appropriate representation for ordinary SQL manipulation—table(s) with primitive, scalar column datatypes.
So I need a PostgreSQL driver for C#. Preliminary research points to Npgsql as the preferred choice.
It seems that I need to install .NET Core first and that this will provide me with: (1) the env to compile and execute a plain “Hello World” C# terminal app; and (2) the env into which I can install Npgsql. (A terminal app is all I need for now.)
Am I right so far? Or have I gone wrong already?
Googling for “Download .NET Core for Linux” took me HERE. The site says “Ubuntu 19.04 Package Manager - Install .NET Core”. And the install steps use “dpkg” and “apt-get”. These are Debian-only tools. (I understand that Ubuntu is based on Debian.)
Obviously, I can create an Ubuntu VM for my prototype work. (I’ll use Parallels on my MacBook.) But I’d prefer to use CentOS. I’ve read that CentOS, like Ubuntu, is forked from Debian. So, before I risk wasting time:
Has anybody installed .NET Core for Linux on CentOS and then written a C# app that does SQL to a PostgreSQL database?
You are on the right path. .NET Core will run on Linux (CentOS or Ubuntu). Npgsql is a .NET Core-compatible library that will run anywhere where .NET Core runs (Linux, Windows, MacOS). Once you properly install .NET Core, use any IDE to create a sample Hello World application (Visual Studio for Mac or Jetbrains Rider are good options). At that point you can add the latest Npgsql Nuget package and try out the getting started code sample from the docs.
Has anybody installed .NET Core for Linux on CentOS and then written a C# app that does SQL to a PostgreSQL database?
I installed the .Net Core on a CentOS 7 and used Npgsql to connect to my PostgreSql Db, and it works just as good as with any other database and connector.
It seems that I need to install .NET Core first and that this will provide me with: (1) the env to compile and execute a plain “Hello World” C# terminal app; and (2) the env into which I can install Npgsql. (A terminal app is all I need for now.)
Am I right so far? Or have I gone wrong already?
That is right so far. I have gone through the same process with a Centos 7 and it works perfectly. To install the .Net core SDK and the .Net core runtime on CentOS you can follow the instructions on the following MSDN link. It is targeting CentOS 7 but the command are sufficiently generic to work directly or with little adaptation effort to a nearby version.
Basically you can run the following commands and you will be done with this part
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
(To register the product key, repository and install required dependencies)
sudo yum install dotnet-sdk-3.1
(To install .Net Core SDK)
sudo yum install aspnetcore-runtime-3.1
(To install Asp.net Core runtime)
sudo yum install dotnet-runtime-3.1
(To install .Net core runtime)
At this step you can use a simple HelloWorld-Like terminal app in which you would add a reference to the Npgsql library using (for example)
dotnet add package Npgsql --version 4.1.2
Your app project will then reflect this change with a package reference tag like:
<ItemGroup>
<PackageReference Include="Npgsql" Version="4.1.2" />
</ItemGroup>
After this step you can configure a database connection string and use the Npgsql data access classes to connect to your database and perform various operations. You could use for instance the link provided by Shay Rojansky for this purpose.
If your .Net core and your Npgsql package are correctly installed, any other issues you could meet would probably be related to
Importing the right namespaces
Ident authentication failures (which could be solved by rightly configuring pg_hba.conf)
I just started to play around with C# application using the .NET framework.
I'm trying to install from Nuget the official neo4j driver package for c# but, despite the fact that from the documentation is stated that it should work with any version of .NET language (here), I got an incompatibility error from one of its dependencies (System.Net.NameResolution 4.0.0)
My application is a Console Application and the target framework is .NET framework 4.5.2.
In particular the error I get is:
Could not install package 'System.Net.NameResolution 4.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.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.
Do you have any idea on how to solve this? I think I'm missing something obvious.
Thanks in advance
Your link states that it works with any .NET language not that it works with any version of the .NET framework. This package appears to be for dotnet core only, so you will need to look into getting started with that.
I am using Visual Studio 2015 the community version.
When I try to add the MySQL Connector in the references it will fail even when I try to add it via NuGet Packages it still fails.
I have tried searching the web for solutions but I kept getting the same result, failure.
I have no idea where to get a .NETCore version of MySQL Connector.
Here is my error
As your exception image suggested, the error is clearly:
The project targets '.NETCore' while the file reference targets '.NetFramework'. This is not a supported scenario.
To see the difference between them, you can refer to the answer here: How does Windows 8 Runtime (WinRT / Windows Store apps / Windows 10 Universal App) compare to Silverlight and WPF? [closed].
For the MySQL Connector for WinRT, you can refer to Chapter 7 Connector/Net Support for Windows Store.
Just tested, you can download mysql-connector-net-6.7.9.msi here, if your device has installed higher version of connector like 6.9.9, you probably need to remove it and install this 6.7.9 version. (Don't know why, as my test result, it seems 6.9.9 doesn't have MySql.Data.RT.dll, didn't look into it, it is possible that I didn't install it correctly, anyway 6.7.9 works for me.)
Then you can find the MySql.Data.RT.dll in your MySQL connector installed path for example: C:\Program Files (x86)\MySQL\MySQL Connector Net 6.7.9\Assemblies\RT, and for UWP app, you can reference this .dll file successfully:
You should follow this guide and install proper .NET Core Connector.
http://insidemysql.com/mysql-connector-net-for-net-core-1-0/
To achieve this, you should use Package Manager Console and follow the guide above.
Let me know if it works for you.
I've just started coding in Visual Studio Code with .NET Core, on Ubuntu 14.04.4
I'm used to both using Ubuntu (from personal interests, hobby, etc) and .NET and Visual Studio at work.
But I've run into a problem i can't seem to overcome. I'm building a small console app that i want to communicate with a MySql Server, but I can't seem to get the MySql.ConnectorNET.Data working properly.
It was installed with the command dnu install MySql.ConnectorNET.Data And that seemed to work fine. The dependency was added in the project.json file, and intellisense was able to traverse the package just fine, but the OmniSharp Log reports that:
[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Project /home/<username>/VSCode/SimpleSQLatmpt/project.json has these unresolved references: MySql.ConnectorNET.Data
and I simply can't seem to fix that. VSCode seems to detect it, and asks me to run the dnu restore command. But it's to no avail. For all intends and purposes it seems like MySql.ConnectorNET.Data is available in the project, but just can't be used.
Can any one tell me how to fix this?
And just as important, why it is happening in the first place?
Thank you very much for your time.
At the time of this question (Mar 2016) there was no .NET Core-compatible ADO.NET provider for MySQL.
Now situation is changed:
MySqlConnector written by Bradley Grainger -- licensed under MIT, and offers full async support
MySql.Data (>6.10) provided by Oracle (traditionally, GPL)
Personally I prefer MySqlConnector -- it can be used in commercial projects for free (MIT license); also I've tested it with my NReco.Data library under Linux, and it works perfectly in my scenarious. Unfortunately, MySqlConnector doesn't support EF Core yet.
--- UPDATE --
One more .NET Core-compatible MySQL connector + EF Core MySQL provider:
Pomelo.Data.MySql (unfortunately it doesn't implement true async behaviour)
Pomelo.EntityFrameworkCore.MySql
UPDATE 2
MySql Connector NET for .NET Core 1.0 was just released (Sep 2016)
http://insidemysql.com/mysql-connector-net-for-net-core-1-0/
I didn't try Bradley Grainger's connector, but this one from MySQL do not support SSL. :(
So, anybody who wants to use anyway, should connect with ";SslMode=None;" in the connection string.
I am trying to change the .net framework for a android c# app in visual studios 2013. I tried to create a new project with .net framework 4.0 but I still get an error saying that my application is targeting the 4.5 framework. Does anyone know how to force this? The reason I am doing this is that I have a nuget package that uses the 4.0 framework, however if there is a way to get that nuget package to use the 4.5 framework that is an equally valid solution.
You cannot change the .net framework for an Android app. It will always be targeting MonoAndroid.
You cannot use a NuGet package that only assemblies for the .NET framework since they may use parts of the Xamarin Android API that is not supported.
So you are left with finding another NuGet package that supports Android projects or re-compiling the source code in an Android library project so it targets MonoAndroid, which may or may not work depending on what the source code does.