Applying Migrations without database result in error
See original GitHub issueWhen I try to apply migrations without having an existing empty database, it simply crashes with this error
CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file ‘C:\Users\Abhishek SiddhuCatalystApp.mdf’. CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Looking at the error it looks like a simple missing of ending slash in default path
Steps to reproduce
It’s pretty consistent. I have tried it on several projects in the last few months and it gives the same error
PM> update-database Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘60’] CREATE DATABASE [CatalystApp]; Failed executing DbCommand (14ms) [Parameters=[], CommandType=‘Text’, CommandTimeout=‘60’] CREATE DATABASE [CatalystApp]; Microsoft.Data.SqlClient.SqlException (0x80131904): CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file ‘C:\Users\Abhishek SiddhuCatalystApp.mdf’. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean isAsync, Int32 timeout, Boolean asyncWrite) at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName) at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary
2 parameterValues) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Create() at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) ClientConnectionId:037c3501-8ad6-484d-aefb-3188be1b1c0d Error Number:5123,State:1,Class:16 CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file ‘C:\Users\Abhishek SiddhuCatalystApp.mdf’. CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Further technical details
EF Core version: 3.0.0 but i get this error in 2.1 as well Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET Core 3.0 Operating system: Windows 10 IDE: Visual Studio 2019 & 2017
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
@ajcvickers I am unable to reproduce it in .net core 3.1 preview-1, it’s working fine now.
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.
BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we’d like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.