Xamarin Forms and Entity Framework Core NetStandard - xamarin

Recently Xamarin announced support for NetStandard (see https://releases.xamarin.com/stable-release-cycle-7-service-release-1/) and the recently shipped Entity Framework Core supports NetStandard. There was a recent issue with the SQLite.Native package that has been resolved (see https://github.com/aspnet/EntityFramework/issues/4269) but when I build the Android version of a Xamarin Forms application it appears it does not include all the assemblies in the output that are needed by the Entity Framework and therefore the application will not run and crashes on the first line of EF code to retrieve data. The UWP version appears to work just fine so this seems like an issue with Android (possibly iOS too).
Has anyone run into this and know a way around it so that the compiled Xamarin Forms Android application will run using Entity Framework Core to access a SQLite database?
Thank you in advance.

Here are the steps you can follow.
Create a Xamarin.Forms project.
Convert the PCL project's properties to .NET Standard 1.3
Install Entity Framework Core and other EF Core stuffs
I have prepared a small hello world project at Github Here.

need to use -linkskip to inform compiler not to remove references.

Related

Migrate native Xamarin Android app to .Net MAUI

I have a Native Xamarin Android app which is running in Target SDK 30(Android 11). I would like to migrate it into .Net MAUI. I am looking for the steps to do that.
Unable to find a documentation related to that.
Here are two links for your reference.
The article is about Migrating Xamarin.Android Applications to.NET 6. And this about Migrating from Xamarin.Android to.NET 7. It contains two Word docx files NavigationGraph.docx which describes the project and Converting a Xamarin.Android to.Net7.docx describes how to go about the detailed manual migration.
Hope it could help you.
Is there a particular reason why you want to migrate to Maui? Your tags on your post don't indicate any other platform other than Android. If you only want to support Android then I can't think of any reason why you would consider Maui.
Please disregard if that is not the case.

No PCL option for Xamarin project

I'm just getting into Xamarin Forms based app development and most of the articles -- if not all -- that I've come across suggest I create a new Xamarin Forms project using Portable Class Library (PCL) approach.
I'm running the latest version of Visual Studio 2017 15.5.1 and when I start a new Xamarin Forms project, I get the following screen with no PCL option.
Am I missing something?
You Can Select .Net Standard. it is Replacement of PCL.
NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET runtimes (such as .NET Framework, Mono, and .NET Core)
For More Details Please visit : https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/

Can not compile after migrating unified api in xamarin forms

We have migrated the xamarin forms project to unified api.
But we have the strange compile error like this:
Could not AOT the assembly '.../iOS/obj/iPhone/Debug/mtouch-cache/Build/Xamarin.Forms.Labs.dll
So I changed the settings in iOS project's options.
In ios Build Tab of Project options(iOS) I changed the "don't link" to "Link all assemblies".
But the app is crashed when it is started.
xamarin version is 5.7.1(build 17).
xamarin forms's version is 1.3.5.6337.
xamarin forms labs's version is 1.0.1.5.
Please help me if you have the experience with this error.
Replace Xamarin.Forms.Labs with XLabs.Forms.
There has been a major refactoring on how the XLabs project is structured so your existing project based on the 1.x.x will break. The reason for the refactoring was simple; separate functionality that does not depend on Xamarin.Forms into different assemblies. This allows the use of functionality like IoC, Serialization and even platform specific services without referencing XF.
To upgrade:
Uninstall any existing Xamarin.Forms.Labs packages from your
project.
Install XLabs.Forms package to your projects (PCL, iOS, Droid & WP). This will update Xamarin.Forms to the latest stable release (1.4.x)
Refactor code to reference the correct namespaces.

Using Dapper (or other NuGet packages) with Xamarin Android

I am currently working on a Xamarin.Android project for a FieldService app. I looked into the standard Xamarin SQLite.NET component for the Data Access Layer, but it does not meet my needs. (I cannot create a PK with multiple fields, for example).
I tried to use the Dapper framework, since I have more experience with that and I think it's pretty awesome.
Couldn't get it to work with Xamarin.Android. I am using Xamarin with Visual Studio 2013. Anyone who knows how to do this?
I tried 3 ways:
Adding Dapper to a Xamarin.Android Class Library. - No errors, but Dapper was not under the References group in solution explorer and I couldn't use the namespace Dapper
Adding Dapper to a "normal" .net Class Library. - Everything worked, I was able to add it, I could use the Dapper namespace and Query methods etc. BUT there was an error referencing the project to the main Xamarin.Android application project. (different target framework)
Adding Dapper to a Portable Class Library targeting .NET Framework 4.5 and Xamarin.Android. - Error when adding the NuGet package.
Brief question: How to add Dapper (or other NuGet packages) to Xamarin.Android?
Thanks in advance.
The Dapper NuGet package contains assemblies that target:
.NET 3.5
.NET 4.0
.NET 4.5
So you will not be able to the NuGet package with an Xamarin Android project since this project will target MonoAndroid.
Dapper would need to be recompiled against the MonoAndroid target framework, if possible. Otherwise you would need to look at other alternatives.
Looking at the Dapper GitHub site all the various classes available in the NuGet package are from one SqlMapper.cs file which seems to compile inside an Android project.

MvvmCross as "Native" Libraries

I have a project which greatly depends on ServiceStack, unfortunately the V4 releases, which includes PCL release for most platforms(especially after forking out for a Xamarin Licence), is just way out of my price range as an ISV. I have cloned the MvvmCross code but before I start messing around I would like to know what pitfalls I could run into when attempting to create a Non PCL based version compatible with the platforms I target (Currently Xamarin.Android, WPF and WinRT). The idea would be to able to reuse the code for the WPF project to build Android and WinRT clients.
Does anyone have any pointers?
I don't think there is any problem or pitfall with what you are describing - and I don't think you'll need to fork the MvvmCross source.
You should be able to build your apps as native code, and should then be able to reference the MvvmCross PCL libraries directly from the native libraries you are building - you don't need to rebuild MvvmCross to do this. Plenty of people already use MvvmCross using "file linking" rather than PCLs - it's not the default setup encouraged by the Nuget packages, but it still works fine.

Resources