dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.78k stars 3.19k forks source link

EF Core Tools Bug Bash #7358

Closed bricelam closed 2 years ago

bricelam commented 7 years ago

All the work we've done since last October finally shipped in version 1.0.0-msbuild3-final of the tools. There has been significant changes to the code including support for the new MSBuild-based (and CPS-based in VS 2017) projects. We would love to get as many people testing this out as we can (both team and community members alike).

If you find anything that isn't working as expected, please submit an issue and (optionally) link to it from here.

What to use

With Visual Studio 2017 RC or .NET Core SDK 1.0 RC3, install the PMC tools by installing the Microsoft.EntityFrameworkCore.Tools package (like you would any other NuGet package). Use either version 1.0.0-msbuild3-final or 1.1.0-msbuild3-final depending on your version of the EF Core runtime.

Install dotnet ef by adding the following to your projects.

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

Things to test

Variable Values
Frameworks .NETCoreApp, .NETStandard, .NETFramework, ✅ UAP, Xamarin, .NET Native
Platforms AnyCPU, ✅ x86, x64, ARM
OS ✅ Windows, ✅ Linux, ✅ OSX
Project Types Console, Web, ✅ UWP, Class Library, Runtime Component, .xproj
Tools PMC, dotnet ef, ef.exe

Note: Struckthrough items are negative scenarios that should give good error messages.

bricelam commented 7 years ago

Exploratory testing on Ubuntu MATE 16.04 looks good. I targeted:

There was one external issue with Console.ForegroundColor not handling bold/non-dark colors correctly. (e.g. Black and DarkGray both look black; Gray and White both look gray)

bricelam commented 7 years ago

Testing netcoreapp1.1, cross-targeting & standalone apps looks good.

Interestingly, making an app standalone only affects publish now, so we can stop worrying about when working on our tools.

bricelam commented 7 years ago

Found one: Unknown commands just show help without erroring. #7386

ajcvickers commented 7 years ago

Tests UWP app with 1.1 on 32-bit Windows 10:

iwaszko commented 7 years ago

Just a quick question: I'm testing on a mac with VS Code. Is it OK to use Microsoft.EntityFrameworkCore.Tools.DotNet version 1.0.0-msbuild3-final with EF Core 1.1.0? Version 1.1.0-msbuild3-final of dotnet ef doesn't seem to be available.

bricelam commented 7 years ago

@iwaszko Yes. There is only one version of Microsoft.EntityFrameworkCore.Tools.DotNet, and it will work with any version of EF Core.

We are considering releasing both a 1.0.0 and 1.1.0 version for RTM to avoid this confusion. (cc @rowanmiller)

iwaszko commented 7 years ago

Thanks, using 1.0.0-msbuild3-final I was able to successfully run dotnet ef migrations add and dotnet ef database update in .csproj-based project on EF Core 1.1.0.

bricelam commented 7 years ago

W00t! Thanks for helping us bash.

leolorenzoluis commented 7 years ago

For some reason, when running dotnet ef database update 0 it gives me the ff error: I have 1.1.0-ms-build-final and EF core 1.1.0

Heres my cs proj:

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-msbuild3-final" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild3-final" />
  </ItemGroup>
System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Microsoft.EntityFrameworkCore.Infrastructure.RelationalServiceCollectionExtensions.AddRelational(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.SqlServerServiceCollectionExtensions.AddEntityFrameworkSqlServer(IServiceCollection services)
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_1.<GetOrAdd>b__2(Int64 k)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.EntityFrameworkCore.DbContext.InitializeServices()
   at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
   at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
MarkusEgle commented 7 years ago

Issue with web template auth Individual on Lubuntu 16.04 Tried with latest bits from https://github.com/dotnet/cli currently 1.0.0-rc4-004777

dotnet ef --version

No executable found matching command "dotnet-ef"

Steps to reproduce:

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 dotnet --version 1.0.0-rc4-004777 mkdir testweb cd testweb dotnet new mvc --auth Individual dotnet restore dotnet run

Everything fine so far. But when testing http://localhost:5000/Account/Register creating a user throws an error:

fail: Microsoft.EntityFrameworkCore.Query.RelationalQueryCompilationContextFactory[1] An exception occurred in the database while iterating the results of a query. Microsoft.Data.Sqlite.SqliteException: SQLite Error 1: 'no such table: AspNetUsers'. at Microsoft.Data.Sqlite.Interop.MarshalEx.ThrowExceptionForRC(Int32 rc, Sqlite3Handle db) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) at Microsoft.Data.Sqlite.SqliteCommand.d__53.MoveNext()

This error tells me to create the database. But dotnet ef database update as well as dotnet ef --version gives the error:

No executable found matching command "dotnet-ef"

apt list --installed|grep sqlite

libsqlite3-0/xenial,now 3.11.0-1ubuntu1 amd64 [installed] libsqlite3-dev/xenial,now 3.11.0-1ubuntu1 amd64 [installed] python-pysqlite2/xenial,now 2.7.0-1 amd64 [installed] sqlite3/xenial,now 3.11.0-1ubuntu1 amd64 [installed]

bricelam commented 7 years ago

@MarkusEgle It looks like that template doesn't include the dotnet-ef tool. Add the following to your *.csproj.

<ItemGroup>
  <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
                          Version="1.0.0-msbuild3-final" />
</ItemGroup>
bricelam commented 7 years ago

But @mlorbetske fixed it in dotnet/templating@fbec36e815df730e06027488e307bf9953a2d77e

MarkusEgle commented 7 years ago

@bricelam Yes... perfect now the template is working on linux including logging in that stores to the sqlite database

jamiewest commented 7 years ago

Just throwing in my experience, I am using cli 1.0.0-rc4-004777 and used the following command

dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet --version 1.0.0-msbuild3-final

but unfortunately I end up with this in .csproj

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

when it would be cool to end up with

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
                            Version="1.0.0-msbuild3-final" />
</ItemGroup>
bricelam commented 7 years ago

@jamiewest We have the appropriate metadata in our nupkg, but NuGet hasn't implemented the logic to handle it yet. This is a known issue, thanks!

caleblloyd commented 7 years ago

I have found at least 2 blocking defects in 1.0.0-msbuild3-final when BaseIntermediateOutputPath is set. Details and full recreate instructions at: https://github.com/aspnet/EntityFramework/issues/7685

MarkusEgle commented 7 years ago

With the latest github release https://dotnetcli.blob.core.windows.net/dotnet/Sdk/rel-1.0.0/dotnet-dev-ubuntu.16.04-x64.latest.tar.gz dotnet --version

1.0.0-rc4-004911

the template dotnet new mvc --auth Individual -f netcoreapp1.0 seems to create entries that are not working currently under linux ubuntu 16.04.

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
  </ItemGroup>

When I "correct" it to:

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

it works, otherwise I will get

/opt/dotnet/sdk/1.0.0-rc4-004911/NuGet.targets(97,5): error : Unable to resolve 'Microsoft.VisualStudio.Web.CodeGeneration.Tools (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'. [/home/myusername/testweb/testweb.csproj] /opt/dotnet/sdk/1.0.0-rc4-004911/NuGet.targets(97,5): error : Value cannot be null. [/home/myusername/testweb/testweb.csproj] /opt/dotnet/sdk/1.0.0-rc4-004911/NuGet.targets(97,5): error : Parameter name: path [/home/myusername/testweb/testweb.csproj]

bricelam commented 7 years ago

@MarkusEgle We're gearing up for the RTM release. If you add this to your NuGet.Config (like they do in their tests), it should work.

<configuration>
  <packageSources>
    <add key="msbuildtools"
         value="https://dotnet.myget.org/F/msbuildtools/api/v3/index.json" />
  </packageSources>
</configuration>
bricelam commented 7 years ago

I'm going to go ahead and close this issue. As far as we can tell, the 1.0.0-msbuild3-final tools have been considerably more stable for people. There are a handful of minor fixes and enhancements going into 1.0.0. Please continue to file issues for anything you find.

deshazer72 commented 7 years ago

hi this is my project.json and

`{ "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0", "type": "platform" }, "Microsoft.AspNetCore.AngularServices": "1.0.0-*", "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview2-final", "type": "build" }, "Microsoft.Extensions.Logging": "1.1.0", "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0", "Microsoft.EntityFrameworkCore.Relational": "1.1.0", "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0", "Microsoft.EntityFrameworkCore.Relational.Design": "1.1.0", "Microsoft.AspNetCore.Diagnostics": "1.1.0", "Microsoft.AspNetCore.Mvc": "1.1.1", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", "Microsoft.AspNetCore.StaticFiles": "1.1.0", "Microsoft.Extensions.Configuration.CommandLine": "1.1.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", "Microsoft.Extensions.Logging.Console": "1.1.0", "Microsoft.Extensions.Logging.Debug": "1.1.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0" },

"tools": { "Microsoft.EntityFrameworkCore.Tools.DotNet": " 1.1.0-preview4-final", "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final", "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", "Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final" },

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

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

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

"publishOptions": { "include": [ "appsettings.json", "ClientApp/dist", "node_modules", "Views", "web.config", "wwwroot" ] },

"scripts": { "prepublish": [ "npm install", "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod", "node node_modules/webpack/bin/webpack.js --env.prod" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] },

"tooling": { "defaultNamespace": "HannaOilGas" } } ` when I try to scaffold my database I get this error Unrecognized option '--build-base-path'

manuelmejiaio commented 7 years ago

I just installed System.Diagnostics.DiagnosticSource and System.Collections.Immutable from the NuGet Package Manager, and everything is working :)