0

Just followed the install instructions on https://www.microsoft.com/net/core#linuxubuntu and https://learn.microsoft.com/en-us/aspnet/core/getting-started

Everything is fine so far, except when creating a new user under http://localhost:5000/Account/Register it fails with

SQLite Error 'no such table: AspNetUsers'

SQLite Error  'no such table: AspNetUsers'

Tried with dotnet ef database update to create the table structure but it fails with version errors.

enter image description here

Now I got lost with all the different versions in the project.json, when to use 1.1.0 and when 1.0.0, when should it be preview1-final preview2-final preview3-final or even better preview2-update1

project.json out of the box after dotnet new -t web

{
  "userSecretsId": "aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a",

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0-preview1-001153-00",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.1",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-update1",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-update1",
      "type": "build"
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.Extensions.SecretManager.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "tooling": {
    "defaultNamespace": "WebApplication"
  }
}

Asp.net core - no such table: AspNetUsers and seems similar but it is windows.

enter image description here

How to update project.json to get the initial ASP.net core template working with saving to SQlite? Or is anything else missing regarding SQlite on Ubuntu? libsqlite3-0:amd64 in version 3.14.1-1build1 is installed...

Community
  • 1
  • 1
MarkusEgle
  • 2,795
  • 4
  • 41
  • 61

2 Answers2

1

I had this same issue while I was developing on a MAC and deploying to Debian. I ended up copying the database file from my development machine to the production server. If you inspect the database file that was produced from the publish command it is empty. Hope this helps you!

  • Opened an issue https://github.com/aspnet/EntityFramework/issues/7211#issuecomment-272156551 and have done a few more tries with using Ubuntu 16.04 and several different dotnet core versions. E.g. `dotnet core sdk 1.0 preview4 build 004233`
    It seems that in newer versions of the web template (`dotnet new -t web`) the user administration (using the entity framework and sqlite) has been deleted. Calling `dotnet ef database update` caused in an error like executable not found. My intention with trying dotnet asp.net core was to evaluate if it is ready to start a commercial project. It's not.
    – MarkusEgle Jan 17 '17 at 13:05
0

With the latest bits (1.0.0-rc4-004777) from github and some help on github (EF Core Tools Bug Bash #7358) I got a solution

wget https://dotnetcli.blob.core.windows.net/dotnet/Sdk/rel-1.0.0/dotnet-dev-ubuntu.16.04-x64.latest.tar.gz
sudo mkdir /opt/dotnet
sudo tar zxvf dotnet-dev-ubuntu.16.04-x64.latest.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
mkdir testweb
cd testweb
dotnet new mvc --auth Individual
dotnet restore

Edit the .csproj and add

<ItemGroup>
  <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
                          Version="1.0.0-msbuild3-final" />
</ItemGroup>

After saving the .csproj you will be able to create the database and the template will run fine.

dotnet restore
dotnet ef database update
dotnet run

With all the above it is possible now running the template under Linux and create users and log in http://localhost:5000/Account/Register and the EntityFrameworkCore stores to sqlite.

MarkusEgle
  • 2,795
  • 4
  • 41
  • 61