Closed PhilPJL closed 2 years ago
I'm having the exact same issue. I upgraded an existing EF 6.2 project to 6.3 RC1 in preparation for the final release, so we can finally migrate to ASP.NET Core without having to upgrade to EF Core for now, which is more problematic. The PowerShell commandlets fail with the same error: "A version of Entity Framework older than 6.3 is also installed". The csproj had been previously updated to the 2017/2019 format removing all the compile references, adding the Package references and so on.
I also realized that migrate.exe is gone and there is a new ef6.exe, so I tried that out in order to update a database and add migrations. For the first case, I got it working without much hassle, but I had to run the command from the bin/Debug/net48 folder rather than from the project folder:
ef6.exe database update --assembly <MyAssembly>.dll --config "..\..\..\..\<ApiProject>\Web.config" --connection-string-name "<DbContextConnectionString>"
However, when adding migrations, the EmbeddedResource entry was not created:
ef6.exe migrations add <NewMigration> --assembly <MyAssembly>.dll --config "..\..\..\..\Loc.Cms.Api\Web.config" --connection-string-name "<DbContextConnectionString>" --project-dir ..\..\..\
I ended up adding the workaround I found here to the csproj: https://github.com/aspnet/EntityFramework6/issues/1225#issuecomment-528571274
<ItemGroup>
<EmbeddedResource Update="Migrations\*.resx">
<DependentUpon>%(FileName).cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.
VS 16.3.0 preview 2 .NET Core 3 preview 8 .NET 4.8 SQL 13.0.5292.0
NET framework
1) create .NET framework class lib 2) add EF 6.2 3) add Context - specifying the connection string "data source=DevSQL;initial catalog=TestDBNetF;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" 4) enable-migrations 5) update-database - database successfully created on 'DevSQL'
6) delete database 7) update to EF 6.3 8) update-database - fails with
A version of Entity Framework older than 6.3 is also installed. The newer tools are running. Use 'EntityFramework\Update-Database' for the older version. update-database : Value does not fall within the expected range. At line:1 char:1
9) try entityframework\update-database - fails as expected I guess
NET core
1) create .NET core 3 class lib 2) add EF 6.3 3) add Context - specifying the connection string "data source=DevSQL;initial catalog=TestDBNetCore;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" 4) enable-migrations 5) update-database -project NetCore -startupproject NetCore
A version of Entity Framework older than 6.3 is also installed. The newer tools are running. Use 'EntityFramework\Update-Database' for the older version. Specify the '-Verbose' flag to view the SQL statements being applied to the target database. System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (53): The network path was not found. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.Open() at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<>c.<Open>b__13_0(DbConnection t, DbConnectionInterceptionContext c) at System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action2 operation, TInterceptionContext interceptionContext, Action
3 executing, Action3 executed) at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) at System.Data.Entity.SqlServer.SqlProviderServices.<>c__DisplayClass60_0.<UsingConnection>b__0() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass2_0.<Execute>b__0() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func
1 operation) at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) at System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action1 act) at System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action
1 act) at System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) at System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable
1 commandTimeout, StoreItemCollection storeItemCollection) at System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) at System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() at System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration) at System.Data.Entity.Infrastructure.Design.Executor.UpdateInternal(String targetMigration, Boolean force, DbConnectionInfo connectionInfo, String migrationsConfigurationName) at System.Data.Entity.Infrastructure.Design.Executor.Update.<>c__DisplayClass0_0.<.ctor>b__0() at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action) ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:53,State:0,Class:20 A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)6) Change connectionstring to just "TestDBNetCore" 7) update-database -project NetCore -startupproject NetCore
Now succeeds but creates the database on (localdb)\mssqllocaldb, not where I want it on DevSQL. DevSQL is an alias to my local machine. Using (local) or the explicit machine name both result in the same error. Yes, named pipes is enabled.
Confirmed this issue on 2 machines.