Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mvc-ef Migration #2

Closed
cevarief opened this issue Apr 24, 2016 · 4 comments
Closed

Mvc-ef Migration #2

cevarief opened this issue Apr 24, 2016 · 4 comments

Comments

@cevarief
Copy link

Hi, it's me again.

Does it work to create migration dotnet ef migrations add Init using mvc-ef sample ?

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ArgumentNullException: Value cannot be null.
Parameter name: assemblyName
   at System.Reflection.AssemblyName..ctor(String assemblyName)
@kerryjiang
Copy link
Owner

Do you mean automatic migration?

From the sample of ASP.NET Identity, there might be one piece of code required:

using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                        .CreateScope())
{
            serviceScope.ServiceProvider.GetService<ApplicationDbContext>()
                             .Database.Migrate();
 }

@cevarief
Copy link
Author

I mean code first migrations using ef tools.

"tools": {
    "dotnet-ef": {
      "version": "1.0.0-*",
      "imports": [
        "portable-net45+wp80+win8+wpa81+dnxcore50",
        "portable-net45+win8+wp8+wpa81",
        "portable-net45+win8+wp8"
      ]
    }
  },
...

@kerryjiang
Copy link
Owner

kerryjiang commented Apr 25, 2016

I think you need pass in the connectionString somewhere then the tool can compare the db schema.
The DbContext in .net core doesn't bind a connection string in configuration like .NET does.

@cevarief
Copy link
Author

It's now using Microsoft.EntityFrameworkCore.Tools. EF Issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants