Is it possible to use EF7 for SQLite in an Xamarin Cross Platform PCL targeting iOS, Android, WinPhone, WinStore and UWP? I currently have a PCL for the above scenario using SQLite.NET PCL (https://github.com/oysteinkrog/SQLite.Net-PCL) but would like to look at the possibility of using EF7.
If so, any documentation or samples?
@econner20 Xamarin.Forms is not supported yet. We would like to support it in the future but likely not for the 7.0.0 release. I thought we had an issue tracking it, but it doesn't look like we do, so we'll use this one.
BTW as expected you get an error stating that the package does not support the required platforms when you try to install it.
Could not install package 'EntityFramework.Sqlite 7.0.0-rc1-final'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10', 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.
What about Xamarin.Android and Xamarin.IOS (using native UI)?
@robertbaker - this work will likely light up all that as well
@rowanmiller Is there any road-map on this?
@reader-man not yet. At this stage I think it will be something we tackle once we get 1.0.0 released.
Thank you very much,
Yes its logical, but you know, MS Purchase of Xamarin made a big fuss with .Net developers (the happy kind of fuss), so anything in the .Net Core as a whole, or its parts like the EF Core, is needed to be going to the xamarin/PCL direction.
Hi,
It is very useful that EF Core works on Xamarin.Forms. This scenario would allow the server code can be transferred to a mobile device together with the client side code without any change, allowing very easily implement the execution of an application in off-line mode using the same ORM in both scenarios (on-line and off-line).
Thanks!
Now that 1.0.0 is released, any news on this ?
Hi,
See this link: https://docs.efproject.net/en/latest/efcore-vs-ef6/features.html
Application Models Section.
_EF Core is built to work on Xamarin when support for .NET Standard is enabled in Xamarin._
Good news!
@Suriman If EF Core works with Xamarin.Forms, then the party just began.
Ideally we get .NET Standard support in Xamarin, and then EF Core will work there (since it already targets .NET Standard). We're discussing timelines etc. with the Xamarin team to work out when this would light up. If it ends up being a long way out, then we may look at other options to light up on Xamarin.
Hi @rowanmiller ,
When EF Core supports Xamarin.Forms, what databases will be supported?
SQLite?, MySQL?, Siaqodb? Realm?, VelocityDB?.
Very good news, thanks!
@Suriman Our first priority is local SQLite databases.
@rowanmiller thanks, the timeline is the essence of patients or neglect.
so we don't wait for unlimited time, so please, if a timeline can be given from XF team, then we can order our schedules/projects/ideas accordingly, either to wait, or implement what we need our-self's.
essential support for "mobile first"
My first Attempt to see the problems when installing Microsoft.EntityFrameworkCore.Sqlite, in a Xamarin.Forms solution, that has an android+iOS+UWP+Windows 8.1+ Windows Phone 8.1 projects, and it gave this error, and did not continue:
Could not install package 'Microsoft.EntityFrameworkCore.Sqlite 1.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', 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.
and this is the nuget output:
Installing EF core in a Xamarin.Forms solution.txt
@reader-man that is the expected result, as EF Core does not target those TFMs and Xamarin doesn't yet support .NET Standard, which EF Core does target. This is an interim state while all our technologies catch up with .NET Standard.
I migrated my Xamarin Forms project to project.json and netstandard and all is going well until I try to use EF Core. The problem is when it first hits any EF code I get a System.TypeLoadException: Could not load type 'System.Reflection.TypeExtensions' from assembly 'System.Reflection.TypeExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. error. However it appears that EF Core should be using version 4.1.0 and not 4.0.0 so I am very confused by this message and I am not sure how to get around it.
It appears that this may be because the System.Reflection.TypeExtensions assembly is not included in the output even though the Microsoft.EntityFrameworkCore is included and used in the project although I am still not sure why it says it is looking for 4.0.0 when it errors.
Any suggestions or timelines on getting full Entity Framework Core support into Xamarin Forms projects?
Thank you.
@wjvii . EF Core will be supported in Xamarin.Forms when Xamarin migrates Xamarin.Forms to .NET Standard Library. According to my contacts, it will be in September.
@Suriman https://blog.xamarin.com/net-standard-library-support-for-xamarin/
It's available now.
@rowanmiller what happens now?
Ok, I gave it a try.
Converting xamarin PCL target project to .net standard gave me some hassle but went OK.
For someone whom might have some trouble converting it, just edit package.json like below:
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"Xamarin.Forms": "2.3.1.114"
},
"frameworks": {
"netstandard1.5": {
"imports": "portable-net50+win8+wpa81+wp8"
}
}
}
"imports": "portable-net50+win8+wpa81+wp8"
And I went though EFCore. found few problem.
1) I had to add all of EFCore lib to android project to build successfully. that's fine.
2) Tried to use sqlite. Nuget failed to resolve SQLite.Native 3.12.2 and failed.
Could not install package 'SQLite.Native 3.12.2'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v5.0', 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.
3) (NOT TESTED) looks like EFCore or EFCore.sqlite utilizes System.Reflection.Emit and AFAIK this cannot be used on iOS due to kernel restricts dynamic code generation.
I was soooo close to get party started. damn.
I see there is an updated SQLite.Native package version 3.12.3 that appears to resolve the issue above about the MonoAndroid target version. I was able to compile and run my Xamarin Forms Android project but when I hit the line of EF code to retrieve data from the database it breaks with a System.NotImplementedException: The method or operation is not implemented when executing a simple db.table.ToListAsync();
I am not sure if it is the issue but it appears that the Android bin folder is missing some assemblies that I would think are needed like System.Linq, which does appear in the UWP project.
Is there something that I have to do in the Android project for it to incude the necessary assemblies or is that the wrong conclusion in the first place?
BTW, the UWP version of the app compiles and runs and appears to have all the appropriate assemblies it needs because it can access data in the included SQLite database without a problem.
This is also somewhat related to #255
Not knowing the root cause I was hoping the issue I reported above would be solved by an update to NuGet and so I installed NuGet 3.5 RC this morning and the final build for Android is still missing files required for Entity Framework.
Can the EF Team give us an official update please on the status of EF Core with Xamarin and Xarmarin Forms now that Xamarin has support for .NET Standard.
Thank you.
Clearing up milestone to discuss in triage and with @rowanmiller. From the comment in https://github.com/aspnet/EntityFramework/issues/4269#issuecomment-239036469 it seems that Xamarin's implementation of .NET Standard has issues blocking EF Core from working, and at the minimum we should catch up in our conversation with the Xamarin folks about these.
@wjvii could you include stacktrace of NotImplementedException you hit?
@marek-safar it would be great to get the stack trace from @wjvii but I suspect we are talking about some of the missing ADO.NET APIs listed here: https://bugzilla.xamarin.com/show_bug.cgi?id=29167.
@marek-safar or rather other APIs like DbDataReader.GetFieldValue<T>()
or async APIs in ADO.NET which used to be a problem some time when trying to run EF Core on Mono. But I could be completely wrong if these have already been implemented in Mono and Xamarin.
Mono has 100% netstandard 1.6 API coverage so missing API should not be the problem.
@marek-safar do you know if the 100% coverage actually means that all .NET Standard 1.6 APIs are implemented or is it possible that some are still just method stubs that throw NotImplementedException
? That would allow types to be loaded and members bound but would still fail at runtime depending on what APIs are invoked.
Yes, that's the case. We haven't reviewed all entry points (thousands of them) yet whether they somewhere down the path throw NIE. That's why I asked for stacktrace of NIE to check this individual case.
When it is applicable to use its Entity Framework in Xamarin?
When the first prereleas comes?
@divega it looks like most of System.Data has been replaced in mono.
https://bugzilla.xamarin.com/show_bug.cgi?id=29167
https://github.com/mono/mono/commit/3d46f1d9c74231936899c11dd336715111a2008f#diff-8cc262a9d1f780f204627f752ccd50f5R1
I believe this is in prevision of the Connect(); conference next month, for announcement of availability of preview of EF Core on Xamarin
@decriptor yes, that seems correct. Also @wjvii has reported on email that the following combination has worked correctly for him in a simple Android application:
Clearing up milestone to decide any further actions in triage.
I tried this some days ago and could add all the packages so far. Except for the Entity Framework Commands or Tools. That would mean that there is no way of scaffolding the db changes for example. Or did I miss something?
Now that Xamarin supports netstandard we are going to do another round of testing and see if we are ready to have Xamarin be one of our supported scenarios. Once we've looked at this we can make a call if we call it supported for 1.1. I'm going to start by porting a sample app I did back in the beta5 days.
@rowanmiller Wondering if you got a chance to do the testing? Eagerly waiting for Xamarin.Forms and Xamarin Android, iPhone & UWP support.
I have just started looking at xamarin and was wondering if xamarin is now supported on EF core 1.1. This is a very much needed item in order to proceed with our development plans.
So far the runtime is looking good from my testing. I've only run in emulators, so I want to deploy to real hardware too.
Tooling is explicitly blocked at the moment, so we'd need to do some work there to enable migrations.
PM> Add-Migration Test
Startup project 'Phoneword' targets framework 'MonoAndroid'. The Entity Framework Core Package Manager Console Tools don't support this framework.
If you are following along with this issue, and excited about EF Core support on Xamarin, then we'd love your help to find outstanding issues.
Please open issues for any problems you hit. Also reply to this thread with a summary of what you tried out, so that we have an idea of what areas were tested and how many folks are bashing on it.
Testing should be done using the 1.1 release. You will also need to add a reference to System.Data
(Project -> Add Reference... -> Framework -> System.Data
in Visual Studio).
PM> Install-Package Microsoft.EntityFrameworkCore.Sqlite
Here is what OnConfiguring
looks like in your derived context to wire up to a local SQLite database.
```c#
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var db = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyData.db");
optionsBuilder.UseSqlite($"Filename={db}");
}
Tooling doesn't work yet (tracked by https://github.com/aspnet/EntityFramework/issues/7152), so you can't use migrations. You need to use `EnsureCreated()` to create the local database.
```c#
using (var db = new MyContext())
{
db.Database.EnsureCreated();
}
Also worth noting that Xamarin.Forms has two options for sharing code between projects, PCL and Shared Code. Our runtime packages currently don't support PCL, so that excludes this option. This may be an acceptable limitation, especially if an MSBuild based .NET Core class library will be an option.
cc @bricelam
@rowanmiller if I'm not mistaking, you can "migrate" your PCL library to NETStandard library, which is compatible with .NET Core and, therefore, EF Core.
I have successfully managed to use EF Core 1.1.0 on a NETStandard 1.4 library referenced by a Xamarin Forms library on an Android app and using the Sqlite data provider. It works well on the emulator and on a device.
About migrations, as @rowanmiller pointed it is not supported from a Xamarin (Android) project but there is a workaround: using a .NET (4.6.1) Console application as the -StartUpProjectName
and specifying the 'model' (NETStandard 1.4) project as the -ProjectName
on the Add-Migration
command. This way the migration and snapshot files are included on the 'model' project and the db.Database.Migrate()
works well (tested on a very simple model).
I will provide all the specific details later (I'm not on my computer).
@polkduran great, thanks for the input! I had the "console app as startup project" idea on my list to experiment with... glad to hear it works.
@polkduran Which SQLite data provider and version did you use?
@econner20 I am using the Microsoft.EntityFrameworkCore.Sqlite
1.1.0 provider which takes sqlite
3.13.0
You can find a working example here
4 projects in the solution:
The MigrationEntryPoint (.NET 4.6.1 Console app) project is used to generate the Migration scripts right on the Model project using the command: Add-Migration MigrationName -OutputDir ../Model/Migrations -Project Model -StartupProject MigrationEntryPoint
.
A Sqlite database is created if it does not exist on the Client.MainPage constructor.
There's only the Android app, I have not tested yet on IOS/Windows.
What is the best practice on how to set the connection string in iOS, Android and UWP? I am assuming it will be DI but are there any examples on the best methods for EFCore?
@econner20 given it's just a local SQLite database, I don't see any issues just setting it inline on the OnConfiguring
method. There are no sensitive credentials etc.
Correct, the database name is being set in the OnConfigure method but I could not call Environment.SpecialFolder.Personal from within the PCL. I used Dependency Services to get the specific path from each of the platforms (iOS, Android and UWP).
DbContext.DataBasePath = DependencyService.Get<ISQLite>().GetDataBasePath();
https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/
@polkduran thank you for the example. It was extremely helpful.
I am having an issue with iOS. I used the example models and context from the example @polkduran provided and was successful in getting EF to work with Android, UWP and a Winforms target. However when I run the same Xamarin project/NETStandard assembly the iOS target is throwing the following exception:
Unhandled Exception:
System.NotImplementedException: Interpreter of ref types
when trying to execute the following:
Person owner = db.People.AsNoTracking().FirstOrDefault();
@econner20 any chance you have a stack trace on the exception?
Unhandled Exception:
System.NotImplementedException: Interpreter of ref types
2016-11-29 13:31:40.313 MobileiOS[27168:602343]
Unhandled Exception:
System.NotImplementedException: Interpreter of ref types
at Microsoft.Scripting.Interpreter.LightCompiler.CompileMethodCallExpression (System.Linq.Expressions.Expression expr) [0x00089] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1283
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x001ba] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1642
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Fra
meworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileConvertUnaryExpression (System.Linq.Expressions.Expression expr) [0x00086] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:684
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x001ff] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1646
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.i
OS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileTryExpression (System.Linq.Expressions.Expression expr) [0x0005a] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1159
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x004a2] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1697
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git
/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileMemberAssignment (System.Linq.Expressions.BinaryExpression node, System.Boolean asVoid) [0x000f5] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:494
at Microsoft.Scripting.Interpreter.LightCompiler.CompileAssignBinaryExpression (System.Linq.Expressions.Expression expr, System.Boolean asVoid) [0x0004e] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:528
at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid (System.Linq.Expressions.Expression expr) [0x00059] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/
Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1602
at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockStart (System.Linq.Expressions.BlockExpression node) [0x000b0] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:405
at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression (System.Linq.Expressions.Expression expr, System.Boolean asVoid) [0x00007] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:376
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x003d0] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-b
uild/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1683
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileTop (System.Linq.Expressions.LambdaExpression node) [0x00055] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:221
at Microsoft.Scripting.Generation.CompilerHelpers.LightCompile (System.Linq.Expressions.LambdaExpression lambda) [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xam
arin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs:619
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System.Core/System.Linq.Expressions.Interpret/LambdaCompiler.cs:41
at System.Linq.Expressions.Expression1[TDelegate].Compile () [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs:195
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.CreateShaper (System.Type elementType, Microsoft.EntityFrameworkCore.Metadata.IEntityType entityType, Micro
soft.EntityFrameworkCore.Query.Expressions.SelectExpression selectExpression) [0x00047] in <f97b8874924247a39fca91e98b024cf6>:0
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitEntityQueryable (System.Type elementType) [0x001cb] in <f97b8874924247a39fca91e98b024cf6>:0
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.EntityQueryableExpressionVisitor.VisitConstant (System.Linq.Expressions.ConstantExpression constantExpression) [0x0003c] in <b004cff6238d4ed08011af53475172bf>:0
at System.Linq.Expressions.ConstantExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs:83
at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00006] in /Users/builder/data/lanes/3969/
44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System.Core/Microsoft/Scripting/Ast/ExpressionVisitor.cs:57
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit (System.Linq.Expressions.Expression node) [0x0000d] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.ReplaceClauseReferences (System.Linq.Expressions.Expression expression, Remotion.Linq.Clauses.IQuerySource querySource, System.Boolean inProjection) [0x00019] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CompileMainFromClauseExpression (Remotion.Linq.Clauses.MainFromClause mainFromClause, Remotion.Linq.QueryModel queryModel) [0x0001f] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.CompileMainFromClauseExpression (Remotion.Linq.Clauses.MainFromClause mainFrom
Clause, Remotion.Linq.QueryModel queryModel) [0x00018] in <f97b8874924247a39fca91e98b024cf6>:0
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitMainFromClause (Remotion.Linq.Clauses.MainFromClause fromClause, Remotion.Linq.QueryModel queryModel) [0x00018] in <b004cff6238d4ed08011af53475172bf>:0
at Remotion.Linq.Clauses.MainFromClause.Accept (Remotion.Linq.IQueryModelVisitor visitor, Remotion.Linq.QueryModel queryModel) [0x00018] in <0a52ab02a5054a9e94c0cd3993f4d33a>:0
at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel (Remotion.Linq.QueryModel queryModel) [0x00012] in <0a52ab02a5054a9e94c0cd3993f4d33a>:0
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel (Remotion.Linq.QueryModel queryModel) [0x0000c] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel (Remotion.Linq.QueryModel queryModel) [0x00036] in <f97b8874924247a39fca91e98b024cf6>:0
at Microsoft.EntityFrameworkCore.
Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult] (Remotion.Linq.QueryModel queryModel) [0x0008f] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult] (Remotion.Linq.QueryModel queryModel) [0x0001c] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult] (System.Linq.Expressions.Expression query, Remotion.Linq.Parsing.Structure.INodeTypeProvider nodeTypeProvider, Microsoft.EntityFrameworkCore.Storage.IDatabase database, Microsoft.Extensions.Logging.ILogger logger, System.Type contextType) [0x0005a] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler+<>c__DisplayClass19_0
1[TResult].
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc] (System.Object cacheKey, System.Func1[TResult] compiler) [0x0001e] i
n <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult] (System.Object cacheKey, System.Func
1[TResult] compiler) [0x00000] in
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery[TResult] (System.Linq.Expressions.Expression query) [0x00049] in
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult] (System.Linq.Expressions.Expression query) [0x00022] in
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult] (System.Linq.Expressions.Expression expression) [0x00000] in
at System.Linq.Queryable.FirstOrDefault[TSource] (System.Linq.IQueryable1[T] source) [0x00011] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/c
lass/referencesource/System.Core/System/Linq/IQueryable.cs:796
at Mobile.App..ctor () [0x000ad] in E:\Development\Visual Studio Projects\Project1\Mobile\App.xaml.cs:54
at Mobile.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in E:\Development\Visual Studio Projects\Project1\Mobile.iOS\AppDelegate.cs:26
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macio
s/src/UIKit/UIApplication.cs:63
at Mobile.iOS.Application.Main (System.String[] args) [0x00001] in E:\Development\Visual Studio Projects\Project1\Mobile.iOS\Main.cs:17
2016-11-29 13:31:40.319 MobileiOS[27168:602343] Unhandled managed exception:
Interpreter of ref types (System.NotImplementedException)
at Microsoft.Scripting.Interpreter.LightCompiler.CompileMethodCallExpression (System.Linq.Expressions.Expression expr) [0x00089] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1283
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x001ba] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/R
untime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1642
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileConvertUnaryExpression (System.Linq.Expressions.Expression expr) [0x00086] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:684
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x001ff] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.
Dynamic/Interpreter/LightCompiler.cs:1646
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileTryExpression (System.Linq.Expressions.Expression expr) [0x0005a] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1159
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x004a2] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Light
Compiler.cs:1697
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileMemberAssignment (System.Linq.Expressions.BinaryExpression node, System.Boolean asVoid) [0x000f5] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:494
at Microsoft.Scripting.Interpreter.LightCompiler.CompileAssignBinaryExpression (System.Linq.Expressions.Expression expr, System.Boolean asVoid) [0x0004e] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Run
time/Microsoft.Dynamic/Interpreter/LightCompiler.cs:528
at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid (System.Linq.Expressions.Expression expr) [0x00059] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1602
at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockStart (System.Linq.Expressions.BlockExpression node) [0x000b0] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:405
at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression (System.Linq.Expressions.Expression expr, System.Boolean asVoid) [0x00007] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class
/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:376
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x003d0] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1683
at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729
at Microsoft.Scripting.Interpreter.LightCompiler.CompileTop (System.Linq.Expressions.LambdaExpression node) [0x00055] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic
/Interpreter/LightCompiler.cs:221
at Microsoft.Scripting.Generation.CompilerHelpers.LightCompile (System.Linq.Expressions.LambdaExpression lambda) [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs:619
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System.Core/System.Linq.Expressions.Interpret/LambdaCompiler.cs:41
at System.Linq.Expressions.Expression
1[TDelegate].Compile () [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Micros
oft.Scripting.Core/Ast/LambdaExpression.cs:195
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.CreateShaper (System.Type elementType, Microsoft.EntityFrameworkCore.Metadata.IEntityType entityType, Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression selectExpression) [0x00047] in
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitEntityQueryable (System.Type elementType) [0x001cb] in
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.EntityQueryableExpressionVisitor.VisitConstant (System.Linq.Expressions.ConstantExpression constantExpression) [0x0003c] in
at System.Linq.Expressions.ConstantExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xa
marin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs:83
at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00006] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System.Core/Microsoft/Scripting/Ast/ExpressionVisitor.cs:57
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit (System.Linq.Expressions.Expression node) [0x0000d] in
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.ReplaceClauseReferences (System.Linq.Expressions.Expression expression, Remotion.Linq.Clauses.IQuerySource querySource, System.Boolean inProjection) [0x00019] in
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CompileMainFromClauseExpression (Remotion.Linq.Clauses.MainFrom
Clause mainFromClause, Remotion.Linq.QueryModel queryModel) [0x0001f] in
at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.CompileMainFromClauseExpression (Remotion.Linq.Clauses.MainFromClause mainFromClause, Remotion.Linq.QueryModel queryModel) [0x00018] in
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitMainFromClause (Remotion.Linq.Clauses.MainFromClause fromClause, Remotion.Linq.QueryModel queryModel) [0x00018] in
at Remotion.Linq.Clauses.MainFromClause.Accept (Remotion.Linq.IQueryModelVisitor visitor, Remotion.Linq.QueryModel queryModel) [0x00018] in <0a52ab02a5054a9e94c0cd3993f4d33a>:0
at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel (Remotion.Linq.QueryModel queryModel) [0x00012] in <0a52ab02a5054a9e94c0cd3993f4d33a>:0
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel (Remotion.Linq.QueryModel queryModel) [0
x0000c] in
at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel (Remotion.Linq.QueryModel queryModel) [0x00036] in
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult] (Remotion.Linq.QueryModel queryModel) [0x0008f] in
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult] (Remotion.Linq.QueryModel queryModel) [0x0001c] in
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult] (System.Linq.Expressions.Expression query, Remotion.Linq.Parsing.Structure.INodeTypeProvider nodeTypeProvider, Microsoft.EntityFrameworkCore.Storage.IDatabase database, Microsoft.Extensions.Logging.ILogger logger, System.Type contextType) [0x0005a] in
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler+<>c__Displa
yClass19_01[TResult].<CompileQuery>b__0 () [0x00011] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc] (System.Object cacheKey, System.Func
1[TResult] compiler) [0x0001e] in
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult] (System.Object cacheKey, System.Func1[TResult] compiler) [0x00000] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery[TResult] (System.Linq.Expressions.Expression query) [0x00049] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult] (System.Linq.Expressions.Expression query) [0x00022] in <b004cff6238d4ed08011af53475172bf>:0
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult] (System.Linq.Expressions.Expression expression) [0x00000] in <b004cff6238d4ed08011a
f53475172bf>:0
at System.Linq.Queryable.FirstOrDefault[TSource] (System.Linq.IQueryable
1[T] source) [0x00011] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System.Core/System/Linq/IQueryable.cs:796
at Mobile.App..ctor () [0x000ad] in E:\Development\Visual Studio Projects\Project1\Mobile\App.xaml.cs:54
at Mobile.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in E:\Development\Visual Studio Projects\Project1\Mobile.iOS\AppDelegate.cs:26
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/39
69/44931ae8/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Mobile.iOS.Application.Main (System.String[] args) [0x00001] in E:\Development\Visual Studio Projects\Project1\Mobile.iOS\Main.cs:17
2016-11-29 13:31:40.320 MobileiOS[27168:602343] critical: Stacktrace:
2016-11-29 13:31:40.320 MobileiOS[27168:602343] critical:
Native stacktrace:
2016-11-29 13:31:40.486 MobileiOS[27168:602343] critical: 0 MobileiOS 0x0000000100e56fad mono_handle_native_sigsegv + 253
2016-11-29 13:31:40.487 MobileiOS[27168:602343] critical: 1 libsystem_platform.dylib 0x000000010c7ebbba _sigtramp + 26
2016-11-29 13:31:40.488 MobileiOS[27168:602343] critical: 2 libsystem_pthread.dylib 0x000000010c8092c8 _pthread_keys + 9720
2016-11-29 13:31:40.489 MobileiOS[27168:602343] critical: 3 libsystem_c.dylib 0x000000010c45ffd7 abort + 129
2016-11-29 13:31:40.491 MobileiOS[27168:602343] critical: 4 MobileiOS 0x0000000100fed03f xamarin_unhandled_exception_handler + 47
2016-11-29 13:31:40.492 MobileiOS[27168:602343] critical: 5 MobileiOS 0x0000000100e5787c mono_invoke_unhandled_exception_hook + 92
2016-11-29 13:31:40.493 MobileiOS[27168:602343] critical: 6 MobileiOS 0x0000000100e567ff mono_handle_exception_internal + 5119
2016-11-29 13:31:40.493 MobileiOS[27168:602343] critical: 7 MobileiOS 0x0000000100e553f8 mono_handle_exception + 24
2016-11-29 13:31:40.493 MobileiOS[27168:602343] critical: 8 MobileiOS 0x0000000100dcff6f mono_amd64_throw_exception + 143
2016-11-29 13:31:40.494 MobileiOS[27168:602343] critical: 9 ??? 0x0000000120ddf9e7 0x0 + 4846385639
2016-11-29 13:31:40.494 MobileiOS[27168:602343] critical: 10 ??? 0x00000001254bed60 0x0 + 4920700256
2016-11-29 13:31:40.495 MobileiOS[27168:602343] critical: 11 ??? 0x00000001254bfcec 0x0 + 4920704236
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
The app has been terminated.
Launch failed. The app 'Mobile.iOS' could not be launched on 'iPhone 6 Plus iOS 10.1'. Error: An error occurred while executing MTouch. Please check the logs for more details.
The app has been terminated.
I tried to install it to a portable class library with this targets:
But got the this message:
Package Microsoft.EntityFrameworkCore 1.1.0 is not compatible with portable45-net45+win8+wpa81 (.NETPortable,Version=v4.5,Profile=Profile111). Package Microsoft.EntityFrameworkCore 1.1.0 supports:
- net451 (.NETFramework,Version=v4.5.1)
- netstandard1.3 (.NETStandard,Version=v1.3)
Does it currently not support portable class libraries?
The portable class libraries have to be converted to .NETStandard. I was successful in using NETStandard 1.4. @polkduran provided a link above to an example that includes steps required to convert the PCLs to NETStandard.
@rowanmiller did the stack trace help?
@econner20 opened https://github.com/aspnet/EntityFramework/issues/7158 to track the issue
When I try to run @polkduran sample project, application throwing the following exception:
System.TypeInitializationException: The type initializer for 'System.Diagnostics.DiagnosticSourceEventSource' threw an exception.
when trying to execute the following line:
db.Database.Migrate();
Am I missing something?
I got this error on a 4.6.1 Class Library Test Project:
Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference
To fix it I had to add the package : "System.ComponentModel.Annotations": "4.1.0",
,despite the fact that I added the EF nuget before. Also 4.1.0 is an older version of the package. 4.3 would be the current one.
Also I get on my Tests Project the error: Unable to load DLL 'sqlite3': The specified module could not be found.
Is this not bundled to the EF nuget?
@NPadrutt can you open a new issue for the DataAnnotation error.
cc @bricelam per the bundling of sqlite3.dll
... are there known cases where this wouldn't get pulled in?
The NuGet MSBuild PackageReference stuff has a lot of bugs with transitive dependencies and native assets.
@bricelam would explicitly listing the package with native binaries as a dependency be a potential workaround?
For a second I thought EntityFramework.Core.Sqlite
is fully functional on Xamarin
but unfortunately most of its methods are not implemented and they throw The method or operation is not implemented
exception.
Xamarin Android
Microsoft.EntityFramework.Core
1.10
Microsoft.EntityFramework.Core.Sqlite
1.10
@al1b Have you tried the Microsoft.EntityFrameworkCore.Sqlite
package?
@bricelam Yes, I'm using Microsoft.EntityFrameworkCore.Sqlite
1.1.0.
@al1b does the stack trace look like the one in #7158?
@divega Well yes, I think stack trace looks the one you mentioned with only difference that I'm using MonoDroid
not iOS
.
I provided the stack trace:
System.NotImplementedException: The method or operation is not implemented.
12-09 13:12:35.712 D/Mono ( 2133): DllImport attempting to load: '/system/lib/liblog.so'.
12-09 13:12:35.712 D/Mono ( 2133): DllImport loaded library '/system/lib/liblog.so'.
12-09 13:12:35.712 D/Mono ( 2133): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
12-09 13:12:35.712 D/Mono ( 2133): Searching for '__android_log_print'.
12-09 13:12:35.712 D/Mono ( 2133): Probing '__android_log_print'.
12-09 13:12:35.712 D/Mono ( 2133): Found as '__android_log_print'.
12-09 13:12:35.712 I/MonoDroid( 2133): UNHANDLED EXCEPTION:
12-09 13:12:35.713 I/MonoDroid( 2133): System.NotImplementedException: The method or operation is not implemented.
12-09 13:12:35.713 I/MonoDroid( 2133): at System.Threading.AsyncLocal`1[T].get_Value () [0x00000] in /Users/builder/data/lanes/3540/4a7d97ac/source/mono/mcs/class/corlib/coreclr/AsyncLocal.cs:68
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.Extensions.Caching.Memory.CacheEntryHelper.get_Scopes () [0x00000] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.Extensions.Caching.Memory.CacheEntryHelper.GetOrCreateScopes () [0x00000] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.Extensions.Caching.Memory.CacheEntryHelper.EnterScope (Microsoft.Extensions.Caching.Memory.CacheEntry entry) [0x00000] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.Extensions.Caching.Memory.CacheEntry..ctor (System.Object key, System.Action`1 notifyCacheEntryDisposed, System.Action`1 notifyCacheOfExpiration) [0x00057] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.Extensions.Caching.Memory.MemoryCache.CreateEntry (System.Object key) [0x00006] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.Extensions.Caching.Memory.CacheExtensions.Set[TItem] (IMemoryCache cache, System.Object key, Microsoft.Extensions.Caching.Memory.TItem value) [0x00000] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc] (System.Object cacheKey, System.Func`1 compiler) [0x00025] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult] (System.Object cacheKey, System.Func`1 compiler) [0x00000] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery[TResult] (System.Linq.Expressions.Expression query) [0x0003d] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult] (System.Linq.Expressions.Expression query) [0x00022] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult] (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0
12-09 13:12:35.713 I/MonoDroid( 2133): at System.Linq.Queryable.Count[TSource] (IQueryable`1 source, System.Linq.Expressions.Expression`1 predicate) [0x00022] in /Users/builder/data/lanes/3540/4a7d97ac/source/mono/external/referencesource/System.Core/System/Linq/IQueryable.cs:1075
12-09 13:12:35.713 I/MonoDroid( 2133): at FirstCodeApp.Android.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00067] in E:\Documents\Projects\FirstCodeApp.Android\FirstCodeApp.Android\MainActivity.cs:40
12-09 13:12:35.713 I/MonoDroid( 2133): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/3540/4a7d97ac/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2426
12-09 13:12:35.713 I/MonoDroid( 2133): at (wrapper dynamic-method) System.Object:c6bb0bf1-33a7-4cea-9848-285ddef0ac9d (intptr,intptr,intptr)
12-09 13:12:35.716 D/Mono ( 2133): DllImport searching in: '__Internal' ('(null)').
12-09 13:12:35.716 D/Mono ( 2133): Searching for 'java_interop_jnienv_new_string'.
12-09 13:12:35.716 D/Mono ( 2133): Probing 'java_interop_jnienv_new_string'.
12-09 13:12:35.716 D/Mono ( 2133): Found as 'java_interop_jnienv_new_string'.
12-09 13:12:35.721 W/art ( 2133): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
12-09 13:12:35.722 D/Mono ( 2133): DllImport searching in: '__Internal' ('(null)').
12-09 13:12:35.722 D/Mono ( 2133): Searching for 'java_interop_jnienv_throw'.
12-09 13:12:35.722 D/Mono ( 2133): Probing 'java_interop_jnienv_throw'.
12-09 13:12:35.722 D/Mono ( 2133): Found as 'java_interop_jnienv_throw'.
An unhandled exception occured.
Hi.
I´m having a runtime error in a Xamarin.iOS NetStandard 1.4 project using EFCore :
{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotImplementedException: Interpreter of ref types
The program fails accesing a DbSet (Residents) of my DbContext, something like context.Residents.
This problem only ocurs in xamarin.ios project. Same code works well on xamarin.droid.
I´m using Microsoft.EntityFrameworkCore 1.1.0, Microsoft.EntityFrameworkCore.Relational 1.1.0 and Microsoft.EntityFrameworkCore.Sqlite 1.1.0 .
Looks like EFCore is using System.Reflection.Emit to access the data. This is a problem in xamarin.ios development https://developer.xamarin.com/guides/ios/advanced_topics/limitations/#No_Dynamic_Code_Generation .
There is any workaround to avoid this runtime error?.
Thanks in advance.
Hi.
I think you must include in Project.json a section imports in .netframework1.4 to allow install the packages back.
Like this:
"frameworks": {
"netstandard1.4": { "imports": "portable-net45+win8+wpa81+wp8" }
}
From: abdu292 [mailto:[email protected]]
Sent: sábado, 24 de diciembre de 2016 13:10
To: aspnet/EntityFramework
Cc: Daniel Silvestre Rojas; Comment
Subject: Re: [aspnet/EntityFramework] Xamarin support (#4269)
@polkduranhttps://github.com/polkduran I have been trying to create something like yours, but with no joy so far.
May I know how did you do that? Did you detach all the projects before doing this?
I am using VS 2017 RC. Thanks!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/aspnet/EntityFramework/issues/4269#issuecomment-269081915, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AXgffirghAR-DaDgA1Y_rVxJ9SY0GH2nks5rLQu1gaJpZM4HBw4X.
NOTA LEGAL
Le informamos que el correo electrónico y las comunicaciones por medio de Internet no permiten asegurar ni garantizar la confidencialidad de los mensajes transmitidos, asà como tampoco su integridad o su correcta recepción, por lo que el emisor no asume responsabilidad alguna por tales circunstancias. Este mensaje va dirigido, de manera exclusiva, a su destinatario y contiene información confidencial y sujeta al secreto profesional, cuya divulgación esta prohibida. En caso de haber recibido este mensaje por error, le rogamos que nos lo comunique mediante correo electrónico remitido a nuestra atención y proceda a su eliminación, asà como a la de cualquier documento adjunto al mismo. Asimismo, le comunicamos que la distribución, copia o utilización de este mensaje, o de cualquier documento adjunto al mismo, cualquiera que fuera su finalidad, están prohibidas por la ley.
La información que haya puesto en nuestro conocimiento, consta en un fichero titularidad de APHELION SOLUCIONES INFORMATICAS, S.L. con el objeto de mantener el contacto comercial con Ud. establecido. Puede ejercer los derechos de acceso, rectificación, cancelación y en su caso oposición enviando un escrito al efecto, acompañado de una fotocopia de su D.N.I. a la siguiente dirección: APHELION SOLUCIONES INFORMATICAS, S.L. C/ Helsinki 52, nº 6-B, Entresuelos nº 1 – 2 y 4.Parc Central 46900 Torrent (Valencia) Spain. Asimismo, es su responsabilidad comprobar que este mensaje o sus archivos adjuntos no contengan virus informáticos, y en caso que los tuvieran eliminarlos.
LEGAL NOTICE
Please note that e-mail and communications through the Internet can not assure or guarantee the confidentiality of messages transmitted, and neither their integrity or proper receipt, so the issuer does not assume any responsibility for such circumstances. This message is addressed, exclusively to its recipient and contains confidential information and subject to professional secrecy, disclosure of which is forbidden. If you have received this message in error, please notify us by e-mail and delete the message as well as any document attached to it. Please also note that the distribution, use or copy of this message or any attachment to it, whatever its purpose, is prohibited by law.
The information which you have placed in our knowledge is registered in a file owned by APHELION SOLUCIONES INFORMATICAS, S.L. and is aimed at maintaining the commercial contact set up with you. You can exercise your rights of access, rectification, cancellation and opposition by sending a letter to that effect, together with a photocopy of your ID card to the following address: APHELION SOLUCIONES INFORMATICAS S.L. C/ Helsinki 52, nº 6-B, Entresuelos nº 1 – 2 y 4. Parc Central 46900 Torrent (Valencia) Spain. It is also your responsibility to see that this message or its attachments do not contain computer viruses, and if they do, that you eliminate them.
Here is a sample using SQLite showing Xamarin.Android working with EF Core 1.1. However I believe Xamarin.iOS still relies on https://bugzilla.xamarin.com/show_bug.cgi?id=32180 in which work would need to be done in the interpreter.
https://www.dropbox.com/s/e9uz1dtaz0rgt43/EntityFrameworkXamarin.zip?dl=0
@JonDouglas: Are you saying @al1b's problem is fixed, we can now use EF Core on Xamarin.Droid?
@JonDouglas @dasilroAdd Are "imports" still necessary? I've managed to successfully reference and use my .dll from my Xamarin project (without EF Core right now).
@JonDouglas @christallire Is Microsoft.NETCore.Portable.Compatibility necessary? Please explain.
@dasilroAdd Yeah. That's was it. I was missing the "imports". Thank you!
@JonDouglas Thanks for the sample. That looks good. I actually misunderstood it was done incorrectly seeing the "Migrations" folder in the console app. @polkduran also has a similar sample above. I am still exploring though.
@bugmenot2 Please refer to my sample for most of your questions. I will do my best to answer your questions.
async
stacktrace, I would guess they might be using the async
flavored methods. My sample just uses the plain-jane sync
methods.12-09 13:12:35.713 I/MonoDroid( 2133): System.NotImplementedException: The method or operation is not implemented.
12-09 13:12:35.713 I/MonoDroid( 2133): at System.Threading.AsyncLocal`1[T].get_Value () [0x00000] in /Users/builder/data/lanes/3540/4a7d97ac/source/mono/mcs/class/corlib/coreclr/AsyncLocal.cs:68
However changing my sample to use async/await
methods instead, it still works fine in Xamarin.Android. I would have to see a sample from @al1b to truly understand that issue.
If you can go into a little more depth and history on this topic I can investigate it further. If you are referring to what the respective project.json
imports
should be, please have a look into the sample. I don't believe they are needed unless you are referencing an old PCL Profile
. I've included them as you may need them if you wanted to use Xamarin.Forms
. However you should be able to omit them in my sample and it should work.
I believe that library is used for packages that have not been updated to the netcore/netstandard
and rather uses the old PCL flavor.
@abdu292 The reason behind this is that you need to have a "Bait" project to create your migrations as the Microsoft.EntityFrameworkCore.Tools
(netstandard
) have been replaced with Microsoft.EntityFrameworkCore.Tools.DotNet
(netcore
) and depends on .NETCoreApp 1.0
. Thus I generated the Migrations
via a netcore
console app and copied them over to the netstandard
library project. Otherwise you will run into a "no table created" type of error.
@JonDouglas You actually don't have to do that. If you see @polkduran 's project sample, using the proper migration command (mentioned in his post above) the "Migrations" folder will be created on the Xamarin .NET Standard Library project. However we indeed requires a "Bait" project to create migrations.
@JonDouglas
However changing my sample to use async/await methods instead, it still works fine in Xamarin.Android. I would have to see a sample from @al1b to truly understand that issue.
I've attached my sample project, you can take a look if you needed to.
Data model:
public class LogAction
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int LogId { get; set; }
public DateTime? CreatedAt { get; set; }
[StringLength(255)]
public string Message { get; set; }
public LogType Type { get; set; }
}
public enum LogType
{
Error,
Startup
}
MyDbContext class:
public class MyDbContext : DbContext
{
public DbSet<LogAction> Logs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var db = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyData.db");
optionsBuilder.UseSqlite($"Filename={db}");
}
}
I used the code below to create database, insert records and query on it. Creating database and inserting records works fine but when I try to execute any query it will throw a NotImplementedException
exception:
var totalStarts = 0;
using (var db = new FirstCodeApp.Database.MyDbContext())
{
db.Database.EnsureCreated();
var log = new LogAction()
{
CreatedAt = DateTime.Now,
Type = LogType.Startup,
Message = $"App has started."
};
db.Add(log);
db.SaveChanges();
// will throw NotImplementedException
totalStarts = db.Logs.Count(l => l.Type == LogType.Startup);
}
@abdu292 Either way, a bait project is needed to generate the Migrations
. My method might be slightly different than having the command output the items in a different folder. Both ways should work just fine!
@al1b I've been able to query just fine:
I'll have a look into your project to see what's going on.
@JonDouglas
I see.
May I ask what version of EF you are using?
@al1b I'm using all the stable bits. 1.1
. The project I attached above has more information. For your sample, you're using a potential myget
or private feed? Can you include that in your project as I don't know where some of these versions are found at!
@JonDouglas
I will take a look on your project, thanks.
Let me think, at the first I used packages from NuGet
and it didn't worked ( NotImplementedException ), Then I tried https://www.myget.org/F/aspnetvnext/api/v2/
repository to install some nightly build packages.
I can change packages to Nuget
if it matters?
I wrote a bit of a blog on this to maybe help others with Xamarin.Android. http://www.jon-douglas.com/2016/12/28/xamarin-android-entity-framework/
@JonDouglas
I think I understand what wrong was with my project. I used Shared Project
instead of PCL
. Do you think is it related?
Thanks for your article, I promise I will write a Persian article about EF in Xamarin!
@JonDouglas @al1b Please adopt cross-platform speech (project.json for now)
@JonDouglas following your examples, I came up with something this (I'd prefer to exclude imports, and use netstandard1.6 but I couldn't get the latter to work still):
{
//Project version
"version": "0.0.1",
//Using
"dependencies": {
"NETStandard.Library": "1.6.1",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer" : "1.1.0"
},
//Targetting
"frameworks": {
"netstandard1.4": {
"imports": "portable-net45+win8+wpa81+wp8"
}
}
}
I can restore that project, build it, and reference it from my Xamarin project, but when I try to compile and run the Xamarin project, I get this:
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Microsoft.EntityFrameworkCore, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Microsoft.EntityFrameworkCore.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() Local.Droid
Help, anyone?
@bugmenot2 you need to install "Microsoft.EntityFrameworkCore.Sqlite" on android project as well. (keep doing this for each library when you get similar error)
@bugmenot2 project.json
is on it's way out. There's no need to be using it across the board as Xamarin projects support netstandard
just fine in the current state of things(with or without project.json
). You are more than welcomed to convert the Xamarin example project in your own testing to project.json
. I choose not to as these items will be converted to to MSBuild(.csproj)
in the future.
@JonDouglas I've heard project.json would be phased out, that's why I said "for now". Not sure what you mean about netstandard. Are you even sure it's going to be .csproj and as we know it? Either way, I think project.json is still the correct way to communicate (as this thread testifies), not screenshots and GUI directions.
@abdu292 Thanks, that was it, but why isn't dotnet build sufficient? It is supposed to build dependencies in.
EDIT: I create a (local) nuget package below so that I don't have to manage dependencies manually
@JonDouglas Got
Could not install package 'Microsoft.NETCore.Jit 1.0.2'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', 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.
trying to install to my Xamarin.Droid project my nuget package constructed using the identical project.json
to yours, except for adding .SqlServer to "dependencies"
:(
@bugmenot2 What do you mean SqlServer
? I'm using SQLite
. Can you please post your project.json
that errors out?
@JonDouglas I mean Microsoft.EntityFrameworkCore.SqlServer was an additional dependency, but the same happens with the verbatim project.json from your zip (in EntityFrameworkXamarin/EntityFrameworkXamarin.Core/).
Excluding Microsoft.NETCore.Portable.Compatibility makes the error go away for the compile time, but results in the following error at runtime:
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
This is in contrast to a .NET Core console app which depends on the same package of mine and executes without problems.
FYI, we got word from Xamarin that the issue reported at https://github.com/aspnet/EntityFramework/issues/4269#issuecomment-266083402 by @al1b (the NotImplementedException
coming from AsyncLocal<T>
was fixed some time ago and the fix is available in a Xamarin.Android 7.1.x version that is in preview.
I have a sample project at github here.
Closing as based on other customer reports we believe things generally work with the latest versions of Mono and Xamarin. However we are missing test coverage for Xamarin and we need to figure out how we can do it. I have created a new issue for this: https://github.com/aspnet/EntityFramework/issues/8792.
For anyone that finds new issues in working with EF Core and Xamarin, pelase create new issues with appropriate details and repro code.
Most helpful comment
Now that Xamarin supports netstandard we are going to do another round of testing and see if we are ready to have Xamarin be one of our supported scenarios. Once we've looked at this we can make a call if we call it supported for 1.1. I'm going to start by porting a sample app I did back in the beta5 days.