question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Applying Migrations without database result in error

See original GitHub issue

When 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, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 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, IReadOnlyDictionary2 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:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
abhisheksiddhucommented, Oct 27, 2019

@ajcvickers I am unable to reproduce it in .net core 3.1 preview-1, it’s working fine now.

0reactions
ajcvickerscommented, Oct 25, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Django database migrations are gives no " ...
Your models in app(s): 'django_project' have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py ...
Read more >
Applying Migrations - EF Core
Strategies for applying schema migrations to production and development databases using Entity Framework Core.
Read more >
Managing Migrations - EF Core
Resetting all migrations · Back up your database, in case something goes wrong. · In your database, delete all rows from the migrations...
Read more >
Migrations and Seed Data With Entity Framework Core
Using migrations is a standard way to create and update a database with Entity Framework Core. The migration process has two steps: Creating ......
Read more >
Resetting Entity Framework Migrations to a clean Slate
Usually this happens after a large number of migrations have been applied and I get stuck to where I can't update a database...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found