question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to find package

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
leonardoporrocommented, Oct 23, 2020

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.

1reaction
leonardoporrocommented, Oct 23, 2020

hey @leonardoporro thank you very much, the problem disappeared after updating to 3.1.10 I also noticed I could not use enums (and I was doing it in three different objects), otherwise I would get the same error I got for bool but with the enum type instead.

I am making progress 😊 Unfortunately, I am getting stuck while inserting keyless objects, as I’ve shown before.

System.Private.CoreLib: Exception while executing function: TestDetached. Detached.Mappers: Indexer [System.Int32] doesn't exist in System.Collections.Generic.ICollection`1[TD.Models.RowModifier].

Basically this code is giving me this error, and I don’t know why. When I remove it, it doesn’t throw this error, but EF complains (rightly) there is no key to establish a relationship with the parent object, where a navigation property to the keyless child is set.

[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; }

public Object()
{
    Id = Guid.NewGuid()
}

it looks like Detached doesn’t allow to do this. If you know a workaround please let me know.

I think that Id is working ok, check my previous comment. Would be possible to change the property type to List<> ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to resolve "Unable to find package" nuget error
Open NuGet section · Add a Feed by clicking "+" sign · Restart JetBrains Rider and the problem should be resolved.
Read more >
NuGet Error NU1101
Examine the project's dependencies in Visual Studio to be sure you're using the correct package identifier and version number. Check your NuGet.
Read more >
Package manager cannot find package in offline resources
Open Visual Studio, go to "Debug" --> "Options.." · Search for "Nuget Package Manager" --> General · Click on "Clear All Nuget Cache(s)"...
Read more >
Unable to find package, No packages exist in the nuget
Unable to find package, No packages exist in the nuget · Go to location %appdata%\Nuget on the machine and see Nuget. · If...
Read more >
[Solved] "E: Unable to locate package" Error on Ubuntu
Fixing 'Unable to locate package error' on Ubuntu · 1. Check the package name (no, seriously) · 2. Update the repository cache ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found