Comments (16)
Hello @ClarkHsu ,
We will look at it but I'm afraid that even if we fix it you will still have the issue.
If we fix it for EF Classic
, the issue will keep being raise probably for EF6
.
I have assigned a developer to check it.
Best Regards,
Jonathan
from entityframework-classic.
Hello @ClarkHsu ,
We successfully reproduced the issue.
Obviously, we don't expect both projects are used in the same project.
One problem is that both libraries share the same config section <entityFramework>
One solution on your side is to have different config depending if you use Entity Framework
or Entity Framework Classic
since library name & version are different.
Perharp a better solution that we tested could be to allow you to customize the config section such as:
EntityFrameworkManager.ConfigSectionName = "entityFrameworkClassic";
and providing a config file like this:
<configuration>
<configSections>
<section name="entityFrameworkClassic" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, Z.EntityFramework.Classic, Version=7.0.0.0, Culture=neutral, PublicKeyToken=afc61983f100d280" requirePermission="false" />
</configSections>
<entityFrameworkClassic>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, Z.EntityFramework.Classic">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, Z.EntityFramework.Classic.SqlServer" />
</providers>
</entityFrameworkClassic>
</configuration>
It's something that would work for you?
from entityframework-classic.
Hi Jonathan,
Thanks for your quick response!
I believe letting us to config the section sounds good.
Cheers,
Clark
from entityframework-classic.
Great,
We will release a version supporting it tomorrow night.
from entityframework-classic.
Hello @ClarkHsu ,
The v7.0.18 has been released.
You can now specify a section name by using the ConfigSectionName
options.
Examples:
Z.EntityFramework.Classic.EntityFrameworkManager.ConfigSectionName = "entityFrameworkClassic";
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="entityFrameworkClassic" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, Z.EntityFramework.Classic, Version=7.0.0.0, Culture=neutral, PublicKeyToken=afc61983f100d280" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<entityFrameworkClassic>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, Z.EntityFramework.Classic">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, Z.EntityFramework.Classic.SqlServer" />
</providers>
</entityFrameworkClassic>
</configuration>
Let me know if everything works as expected.
Best Regards,
Jonathan
from entityframework-classic.
Hi Jonathan,
Thumbs up for your quick action!
Indeed, 7.0.18 has eliminated the exception as title describe, but it still not works by other issues.
Condition1 (exactly using your config), will get
No Entity Framework provider found for the ADO.NET provider with invariant name 'Effort.Provider'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderServicesResolver.GetService(Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k)
since it's finding the provider 'Effort.Provider', I changed the config to
Condition2
<providers>
<provider invariantName="Effort.Provider" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
changes are only in section, then I got
Unable to cast object of type 'Effort.Provider.EffortConnection' to type 'System.Data.SqlClient.SqlConnection'.
at System.Data.SqlClient.SqlCommand.set_DbConnection(DbConnection value)
at System.Data.Common.DbCommand.set_Connection(DbConnection value)
at System.Data.Entity.Internal.InterceptableDbCommand.set_DbConnection(DbConnection value)
at System.Data.Common.DbCommand.set_Connection(DbConnection value)
also an attempt to using
Condition3
<provider invariantName="Effort.Provider" type="System.Data.Entity.SqlServer.SqlProviderServices, Z.EntityFramework.Classic.SqlServer" />
but, got
The 'Instance' member of the Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, Z.EntityFramework.Classic.SqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=afc61983f100d280' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(Type providerType)
test code is :
public void TestMethod1()
{
EntityFrameworkManager.ConfigSectionName = "entityFramework";
var dbConnection = DbConnectionFactory.CreateTransient();
TestContext context = new TestContext(dbConnection);
var category = context.TestCategories.Add(new TestCategory { Name = "123", Description = "one two three" });
}
internal class TestContext: DbContext
{
static TestContext()
{
}
public TestContext(DbConnection dbConnection)
: base(dbConnection, false)
{ }
}
It seems no matter when I touch the EF6 things, issues will be raised by it. Could you evaluate whether it can be fixed - by any other small-scale code changes- at your side?
Cheers,
Clark
from entityframework-classic.
Thank Clark for reporting,
We will look at how to make it work with Effort
.
from entityframework-classic.
Hello @ClarkHsu ,
Unfortunately, we are not able to reproduce the Condition1
.
The Condition2
and Condition3
are expected error since the Effort.Provider is not a SQL Connection
.
With Z.EntityFramework.Effort
, did you used the following package: https://www.nuget.org/packages/Z.EntityFramework.Classic.Effort/
You cannot use Effort.EF6
with EF Classic
since the Effort package has been built with EF
and not EF Classic
. Perharp that's the issue?
Best Regards,
Jonathan
from entityframework-classic.
Hi Jonathan,
Could you please try this piece of code?
[TestMethod]
public void TestMethod1()
{
EntityFrameworkManager.ConfigSectionName = "entityFramework";
var dbConnection = DbConnectionFactory.CreateTransient();
TestContext context = new TestContext(dbConnection);
var category = context.TestCategories.Add(new TestCategory { Name = "123", Description = "one two three" }); //Exception thrown here
}
and use System.Data.Entity.DbContex as the base class of context
internal class TestContext: System.Data.Entity.DbContex
{
public DbSet<TestCategory> TestCategories { get; set; }
public TestContext(DbConnection dbConnection)
: base(dbConnection, false)
{ }
}
public class TestCategory
{
public short Id { get; set; }
public string Name { get; set; }
}
Cheers,
Clark
from entityframework-classic.
Still working great,
I will make my developer try it tomorrow and we will provide you with a project if we are still unable to reproduce it.
from entityframework-classic.
Hello @ClarkHsu ,
I believe we successfully reproduced the issue.
After digging in some issue on Effort
, I found one similar to your: zzzprojects/EntityFramework-Effort#42 (comment)
We are currently looking about how we can make a solution that will not involve code on your side.
from entityframework-classic.
Hello @ClarkHsu ,
We didn't success to make it works without additional code but that's certainly something we will continue to dig over next week.
The issue happens normally when an EF Classic context is initialized and the Effort
provider has not been yet registered. The provider cannot anymore be registered and that cause the issue.
One way to make it works in unit tests is making sure the Effort.Provider.EffortProviderConfiguration.RegisterProvider();
is the first command called by the assembly. For example, by using the [AssemblyInitialize]
attribute.
[AssemblyInitialize]
public static void Initialize(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext testContext)
{
Effort.Provider.EffortProviderConfiguration.RegisterProvider();
}
Let me know if you succesfully make it work or you need more help.
Best Regards,
Jonathan
from entityframework-classic.
Hi Jonathan,
Sorry for my late response. But this solution's result is negative. Will still get error of
at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderServicesResolver.GetService(Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k)
And I am sure Effort.Provider.EffortProviderConfiguration.RegisterProvider();
is called at the very beginning using your hint of [AssemblyInitialize]
Cheers,
Clark
from entityframework-classic.
Hello @ClarkHsu ,
Is the issue happen for Entity Framework
or Entity Framework Classic
? (or maybe both).
For EF Classic
, we already coded something that will automatically integrate EF Effort
. Only a few more test tomorrow is required before we release this fix.
from entityframework-classic.
Hello @ClarkHsu ,
Do you have an update on this issue?
from entityframework-classic.
Hello @ClarkHsu ,
This issue will be closed since we believe it's resolved.
If you have more information, feel free to provide it and we will re-open the issue.
Best Regards,
Jonathan
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
- EDMX - Unable to cast object of type ObjectQuery to DbQuery in .Include() HOT 19
- 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.