7

I'm new to ASP.NET and am trying to set up a webAPI c# application with entity framework. But when I try to run the Enable-Migrations command on nuget-package-manager console, I'm getting the following error:

"Cannot bind argument to parameter 'Path' because it is null"

    enable-migrations : Cannot bind argument to parameter 'Path' because it is 
    null.
    At line:1 char:1
    + enable-migrations -ContextTypeName SchoolDBContext
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Enable-Migrations], 
    ParameterBindingValidationException
    + FullyQualifiedErrorId : 
    ParameterArgumentValidationErrorNullNotAllowed,Enable-Migrations

I've tried uninstalling and re-installing entity framework but it still gives the same error.

How can I fix this?

1

9 Answers 9

12

I had this error when using EntityFramework 6.3.0, downgrading it to 6.2.0 fix my issue.

Sign up to request clarification or add additional context in comments.

5 Comments

wow thanks a lot. Downgrading to 6.2 fixed it for me as well!
in my case vs needed a restart also ;)
I would add that 6.4.0 is available and the downgrade should not be required as the upgrade (from 6.3.0) fixed my issue.
Holy cats! I've been messing around with this so long it's embarrassing. It was broken for me in EF 6.4, broken in EF 6.3, works in EF 6.2. Thanks!
It seems like Microsoft EntityFramework Core is now the focus, not EntityFramework. Does it make sense to hope a problem to get EntityFramework 6.4 fixed? I'm not sure how to do it.
4

There is a workaround for this bug. Just edit a file and restart Visual Studio. It works!

Comments

4

I had same error and just update EF to latest version (Here to 6.4.0) Now migrations works well.

update-package entityframework
enable-migrations
Add-Migration InitialCreate

Comments

2

Just use any of the versions of EntityFramework except 6.3.0. In my case using EntityFramework 6.0.0 solved the problem.

Comments

1

Updating EntityFramework packages in my solution from 6.3.0 to 6.4.4 resolved the issue for me.

Comments

0

Have you tried manually adding a database with the appropriate name to match the connection string in your config file?

I had an identical error this afternoon. Adding the database manually fixed the issue and I have subsequently managed to add a migration which added a table.

Following this I removed the Configuration file and the migrations (from the project's 'Migrations' folder), and deleted the database. When I subsequently ran update-database I got the more conventional responses:

Checking if the context targets an existing database...

Code First Migrations enabled for project MyProject.Domain

I then ran 'add-migration Initial' and 'update-database'. This seeded me a new database. All good. Any updates from others about underlying story gratefully appreciated.

2 Comments

I tried manually adding the database but for me it's still producing the same error. But thank you for your input.
Perhaps you could add a little more detail. For example, you say that you have installed Entity Framework to your project, I assume you have added an appropriate connection string to your web.config or app.config file, you have added a context that inherits System.Data.Entity.DbContext and has the appropriate constructors.
0

I get this if I have my database code in a separate class library. To get the commands to work I had to select the class library as the start up project.

So I did the following...

Select the project where the database context exists and right click, select "Set as StartUp Project".

Select the default project as the correct project.

Ensure that you are in the project directory on the filesystem.

Run the commands.

Comments

0

Issue is due to not having sufficient privileges to run the command. Open Visual studio in administrator mode (Run as Administrator) and execute the command.

Comments

0

re-installing EF 6.4.4 after uninstalling 6.1.3 resolved this for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.