Efcore: Error on code-first migration with EntityFrameworkCore.Sqlite

Created on 4 Jul 2016  路  7Comments  路  Source: dotnet/efcore

I am using Visual Studio Community 2015 with Update 3. I did the below :

  1. Created a UWP class library : "EF.Data2"
  2. Updated the : "Microsoft.NETCore.UniversalWindowsPlatform" from 5.1.0 to 5.2.0 (my VS Community Update 3 has 5.1.0 as default template)
  3. Installed nuget package : "Install-Package Microsoft.EntityFrameworkCore.Sqlite" from package manager console
  4. Installed nuget package : Install-Package Microsoft.EntityFrameworkCore.Tools 鈥揚re
  5. Now, I tried to create my first migration with command : Add-Migration MyFirstMigration. But got the below error :
    1
  6. Then following this, added a App.Config file. But still getting the same error :
    2
  7. As the error is giving due to the dependency of : Microsoft.EntityFrameworkCore.Design.Core, I later installed it in my UWP class library, but still getting the error on creating migration file.

This is my project.json file :

{
  "dependencies": {
    "Microsoft.EntityFrameworkCore.Design.Core": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.0"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}
closed-duplicate type-bug

All 7 comments

Running tooling commands on a UWP class library is not currently supported (tracking support for that in #6029).

We will add a more helpful error message to make this clearer. Closing as a duplicate of https://github.com/aspnet/EntityFramework/issues/5878

@yeasin90 you can workaround this by running commands on a UWP app instead.

@natemcmaster Thanks for the workaround. In that case,the DbContext class has to be inside UWP app, right? (POCO classes can be in UWP class library)

Yes. Finally got it working. Did the below steps :

  1. All my POCO classes and DbContext are in UWP class library with Microsoft.EntityFrameworkCore.Sqlite installed
  2. Added app.config file in UWP app following #5471 and set it as startup project
  3. From Package Manager Console, select UWP class library and executed migration command
  4. Migration files were created in UWP class library and subsequent migrations are also applied with context.Database.Migrate().

@yeasin90 Can you share your project or a simple project working?
I'm stuck on this for a week.

@rubgithub : yes sure :) .. not at my desk right now, will upload the sample asap

@rubgithub : created a repo with my sample app. Have a look

Thanks @yeasin90

Was this page helpful?
0 / 5 - 0 ratings