Comments (19)
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.
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.
There is a mini reproduction:
EdmxTest.zip
- EdmxTest - Tests with EF 6 - worsk
- EdmxTestClassic - Tests with Z.EntityFramework.Classic - does not work
from entityframework-classic.
The problem occurred because I use ObjectContext
as a base class instead of DbContext
. And ObjectSet<>
Instead of DbSet
.
from entityframework-classic.
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.
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.
Z.EntityFramework.Plus.Ef6 supports ObjectContext very well.
from entityframework-classic.
I think it should be similar to this implementation:
EntityFramework-Classic/src/Shared/EntityFramework/QueryableExtensions.cs
Lines 464 to 474 in 4953e04
from entityframework-classic.
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.
@JonathanMagnan Any updates?
from entityframework-classic.
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.
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.
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.
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.
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.
Sorry for that, we will look at what we missed
from entityframework-classic.
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.
@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.
One more time thanks for your help and your hard work with the entire Z.EntityFramework.
from entityframework-classic.
Related Issues (20)
- Type not supported yet (LazyType): sdo_geometry HOT 11
- "Cannot bind argument to parameter 'Path' because it is an empty string" when running Add-Migration HOT 9
- Include with InvalidCastException exception HOT 4
- IDbContext HOT 8
- EF6 is available for .NET Core 3+ HOT 1
- HasNoKey and Constructor with Parameters HOT 5
- Make DbMigrator constructors public HOT 4
- Link to entityframework.net HOT 3
- Count() inside string expression in Execute method HOT 4
- Creating new array inside expression string - Execute extension method HOT 8
- Error when using UpdateFromQuery on an expanded query (Linqkit) HOT 3
- DbMigrator - Problems with existing migrations HOT 6
- HierarchyId.GetAncestor method raise an unexpected exception HOT 7
- Current Values are not reset when using SoftDelete HOT 6
- this.Configuration not availalbe in .net core 6 for soft delete HOT 3
- The object cannot be deleted because it was not found in the ObjectStateManager HOT 1
- IDbCommandInterceptor called multiple times on queries with .IncludeOptimizedByPath() HOT 2
- add new provider Microsoft.Data.SqlClient HOT 3
- Unable to load the specified metadata resource. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entityframework-classic.