Giter VIP home page Giter VIP logo

Comments (19)

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024 1

Hello @WojciechNagorski ,

Thank you for reporting and your project (and your good word, always feels great to get those).

My developer will look at it soon.

Best Regards,

Jon

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024 1

Hello @WojciechNagorski ,

Maybe old was indeed not the right way to say this ;) Just that most people generate their code using a DbContext and not anymore the ObjectContext.

Under the hood, EF Plus probably supports it because we use GetOrCreateDbContext in a few places, so it's done automatically for you.

We will look at it to see if we can change some part of our code to make it works the same way.

Best Regards,

Jon

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

There is a mini reproduction:
EdmxTest.zip

image

  • EdmxTest - Tests with EF 6 - worsk
  • EdmxTestClassic - Tests with Z.EntityFramework.Classic - does not work

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

The problem occurred because I use ObjectContext as a base class instead of DbContext. And ObjectSet<> Instead of DbSet.

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024

Hello @WojciechNagorski ,

Look like your project still use the old ObjectContext instead of inheriting of a DbContext.

In this case, some method of our library will requires to use the GetOrCreateDbContext method from our Z.EntityFramework.Extensions.Classic library (already included in EF Classic).

var result = context.GetOrCreateDbContext().Set<Users>().Include(p => p.Project).ToList();

It will transform your ObjectContext into a DbContext and from it, everything should now work as expected.

Let me know if that solution could work for you.

Best Regards,

Jon

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

DbContext is a wrapper of ObjectContext and ObjectContext have different features. It is not old, but not default. EF supports both of them and I think Z.EntityFramework.Classic should support too. I have a huge project and this will be painful for me.

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

Z.EntityFramework.Plus.Ef6 supports ObjectContext very well.

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

I think it should be similar to this implementation:

var asDbQuery = source as DbQuery<T>;
if (asDbQuery != null)
{
return asDbQuery.Include(path);
}
var asObjectQuery = source as ObjectQuery<T>;
if (asObjectQuery != null)
{
return asObjectQuery.Include(path);
}

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

EF Classic should be fully compatible with normal EF. Otherwise, what it doesn't support should be added to the Readme.md.

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

@JonathanMagnan Any updates?

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024

Hello @WojciechNagorski ,

The fix we started was refused 2 weeks ago. Since then, we didn't have any idea how to fix it 2 major errors we had.

On the good side, time did the work, and when I saw your message, the idea about how to fix it comes as well.

So a new branch is currently under review. I cannot guarantee anything but I currently have high hope that this one will be accepted.

I will give you an update when I will have one.

Best Regards,

Jon

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024

Hello @WojciechNagorski ,

Just to let you know that the fix has been accepted.

The fix should be released with our monthly release on 2023-09-12

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024

Hello @WojciechNagorski ,

The v7.2.7 has been finally released.

Let us know if everything is now working as expected with the Include method for the `ObjectContext.

Best Regards,

Jon

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

I have a large project and now I get another exception:

System.Data.Entity.Core.MetadataException: Unable to load the specified metadata resource.
   at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
   at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.SplitPaths(String paths)
   at System.Data.Entity.Core.Common.Utils.Memoizer`2.Result.GetValue()
   at System.Data.Entity.Core.Common.Utils.Memoizer`2.Evaluate(TArg arg)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetArtifactLoader(DbConnectionOptions effectiveConnectionOptions)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions)
   at System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace()
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
   at DatabaseAPI.ContextEntities..ctor() in D:\work\Project\Database\DatabaseModel\DatabaseModelPartials.cs:line 81
   at DatabaseService.DatabaseService.<>c.<.ctor>b__5_0() in D:\work\Project\Database\DatabaseService\DatabaseService.cs:line 133
   at DatabaseService.DatabaseService.GetAllProjects() in D:\work\Project\Database\DatabaseService\DatabaseService.cs:line 442

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

And my mini repro EdmxTest.zip does not work after updating Z.EntityFramework.Classic to 7.2.7

Now there is the following exception:

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.Data.Entity.Core.Objects.ObjectQuery`1[EdmxTestClassic.Users]' to type 'System.Data.Entity.Infrastructure.DbQuery`1[EdmxTestClassic.Users]'.
   at EntityFrameworkClassicExtensions.AsDbQuery[TQuery](IQueryable`1 this)
   at System.Data.Entity.QueryableExtensions.Include[TResult,TProperty](IQueryable`1 source, Expression`1 path)
   at EdmxTest.Program.Main(String[] args) in D:\work\EdmxTest\EdmxTest\EdmxTestClassic\Program.cs:line 14

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024

Sorry for that, we will look at what we missed

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 6, 2024

Hello @WojciechNagorski ,

Could you do a Clean Solution and try it again?

The current repo still use 7.2.5, when upgrading to 7.2.7 and making sure that the newest dll is used by cleaning the solution, we cannot reproduce anymore the problem.

Let make sure this one work before working your larger solution problem.

Best Regards,

Jon

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

@JonathanMagnan You are right. I've Clean Solution and mini repro works.

I'm going to close this issue. My large application still does not work, but I need more time to test everything. I will start a new issue if the problem persists.

from entityframework-classic.

WojciechNagorski avatar WojciechNagorski commented on June 6, 2024

One more time thanks for your help and your hard work with the entire Z.EntityFramework.

from entityframework-classic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.