Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for netcoreapp1.0 #7

Closed
scottdorman opened this issue Jul 1, 2016 · 13 comments
Closed

Add support for netcoreapp1.0 #7

scottdorman opened this issue Jul 1, 2016 · 13 comments

Comments

@scottdorman
Copy link

When trying to install in an ASP.NET Core 1.0 project with AutoMapper v5.0.0 installed, AutoMapper.EF6 fails to restore with the following error:

Package AutoMapper.EF6 0.4.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package AutoMapper.EF6 0.4.0 supports: net45 (.NETFramework,Version=v4.5)

@jbogard
Copy link
Member

jbogard commented Jul 1, 2016

I didn't think EF6 supported NetCore, does it? It's .NET 4.5 only.

@jbogard
Copy link
Member

jbogard commented Jul 1, 2016

Strike that, .NET 4.0 and .NET 4.5. What EF are you using?

@scottdorman
Copy link
Author

scottdorman commented Jul 1, 2016

I'm using EF Core, but this had been working. Here's the scenario:

I have an ASP.NET Core project (created prior to the 1.0 release) that was using AutoMapper 5.0.0-beta-1 and AutoMapper.EF6 0.3.0. Everything worked as expected. I've since upgraded that project to .NET Core 1.0 release and updated to AutoMapper 5.0.0. I can't use any of the AutoMapper.EF6 versions now since they don't support the netcoreapp1.0 profile.

I tried to see if I could get a version compiling against that profile, but the DelegateDecompiler.EntityFramework dependency is very old and doesn't currently support any of the .NET Core stuff. (It was last updated about 6 months ago.)

If this is intended only for EF6 and not EF Core, is there a similar package for EF Core?

@jbogard
Copy link
Member

jbogard commented Jul 1, 2016

It had been working? Maybe when EF Core was EF7, but I never had a package working with EF Core.

The problem with Delegate Decompiler is it relies on reflection tools that are currently ONLY available to full .NET Framework. The APIs simply do not exist in .NET Core, neither do the capabilities.

@scottdorman
Copy link
Author

scottdorman commented Jul 1, 2016

Yes, it had been working. :) Keep in mind, though, that this was prior to the change to using netcoreapp1.0 as the moniker, so that may have had something to do with it.

I saw that issue with Delegate Decompiler as well, which prevents it from being used at all.

In the meantime (only tested with a couple of methods), it seems like I can create a workaround by doing this:

public static class EntityFrameworkExtensions
{
    public static async Task<List<TDestination>> ProjectToListAsync<TDestination>(this IQueryable queryable, IConfigurationProvider config)
    {
        return await queryable.ProjectTo<TDestination>(config).ToListAsync();
    }

    public static async Task<TDestination> ProjectToSingleOrDefaultAsync<TDestination>(this IQueryable queryable, IConfigurationProvider config)
    {
        return await queryable.ProjectTo<TDestination>(config).SingleOrDefaultAsync();
    }

    public static TDestination ProjectToSingleOrDefault<TDestination>(this IQueryable queryable, IConfigurationProvider config)
    {
        return queryable.ProjectTo<TDestination>(config).SingleOrDefault();
    }

    public static List<TDestination> ProjectToList<TDestination>(this IQueryable queryable, IConfigurationProvider config)
    {
        return queryable.ProjectTo<TDestination>(config).ToList();
    }
}

I've been able to test both the async and the non-async versions and they both seem to work. Not sure if there might be any potential issues with that approach though.

@jbogard
Copy link
Member

jbogard commented Jul 1, 2016

One way to get this to work would be to only support net451 (which EF Core does support) and not netstandard1.3, its other target.

@jbogard
Copy link
Member

jbogard commented Jul 1, 2016

Also, the delegate decompiler stuff works with .NET 4.5. So if you didn't want to run on .NET Core, you're set.

Which, if you are.....good luck buddy :)

@jbogard
Copy link
Member

jbogard commented Jul 1, 2016

One last thing, the delegate decompiler EF extension was for async, which doesn't sound like it should be used ATM dotnet/efcore#5816 so I could create and EF core version that uses delegate decompile and targets .NET 4.5.1. Thoughts? It's such a silly little library though, just extension methods.

@scottdorman
Copy link
Author

Yea, it's probably not worth the effort. Do you see anything wrong with the extension methods I showed in this comment? The two (only because those were the two I was previously using) I've tested so far seem to work correctly.

@jbogard
Copy link
Member

jbogard commented Jul 1, 2016

Nope. The extension methods were pretty simple, just stuff we copied and pasted around.

@scottdorman
Copy link
Author

Cool. I'll add the rest of them in so I can keep using them.

@darcythomas
Copy link

Having read through this issue; am I correct that if you used EF core in a 4.5/4.6.1 [not .net core] app then the automapper.EF6 lib will probably work?

@jbogard
Copy link
Member

jbogard commented Oct 11, 2016

Worth a shot, but the underlying dependency I have is on EF6 not EF Core

On Wednesday, October 5, 2016, Darcy notifications@github.com wrote:

Having read through this issue; am I correct that if you used EF core in a
4.5/4.6.1 [not .net core] app then the automapper.EF6 lib will probably
work?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#7 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGYMp2wI8xqjt-N-WAnyLGWSAb6ouDgks5qxHOYgaJpZM4JDGTN
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants