Detached-Mapper: Unable to find package
Hi, I decided to give Detached a try, but when trying to install it in my current project I get
PM> Install-Package Detached.Mappers.EntityFramework
Install-Package : Unable to find package 'Detached.Mappers.EntityFramework'
At line:1 char:1
+ Install-Package Detached.Mappers.EntityFramework
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Time Elapsed: 00:00:03.7855917
It seems it’s not present on the Nuget package Manager. Any workaround?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (13 by maintainers)
Hi again @pinoli Good, I’m glad you were able to sort out all of the library issues.
If you look at this class: https://github.com/leonardoporro/Detached-Mapper/blob/main/src/Detached.Mappers.EntityFramework/Context/EntityFrameworkMapperContext.cs
There is a OnMapperAction method, it receives the entity, the DTO, the key and a MapperActionType: Load/Create/Update/Delete. For Load, a full query is run, in this state, all the entities should be in the ChangeTracker. For the mutation actions, detached tries to get the entity from the change tracker or create a new one, and set the EntityState. That is what you would normally do manually. I think that you could customize this class to suite your needs, but I need to re-read your sample to tell you exactly what (will do later). Once you have your customized mapper context, it can be passed to the mapper class without modifying the library. Take a look at https://github.com/leonardoporro/Detached-Mapper/blob/main/src/Detached.Mappers.EntityFramework/Extensions/DbContextExtensions.cs, line 30 to see how.
Anyway Detached does a kind of upsert, need to read your sample later to see why doesn’t work, my brain is burnt out now.
I think that Id is working ok, check my previous comment. Would be possible to change the property type to List<> ?
ImportJsonAsync: json should start with [ as it is expecting an array.
Hey @pinoli, I just reviewed the code and it was totally my fault! I forget to put Boolean in the list of primitives, so that mapper was considering it an object. There are two solutions:
Sorry for the poor support, it is just only me here. But if we could convince more people to join in…
Here it is the code I used to reproduce the bug: ` class Program { static void Main(string[] args) { Db db = new Db(); db.Database.EnsureCreated();
`
El jue., 22 oct. 2020 15:56, pinoli notifications@github.com escribió:
Hi @pinoli, thank you for giving a try I installed it using
Install-Package Detached.Mappers.EntityFramework -Version 5.0.0-rc.2.20475.6
and worked well. Do you have VS 2019 and net 5 installed? This package is built using EF Core 5 preview (since it seems to be the first decent version of EF Core). I saw over here (https://github.com/dotnet/efcore/issues/23044) that you have the same problem as me and many other people. I’ll be glad to help if you provide a bit more of context.