If your build complains of "Could not load file or assembly 'Microsoft.EntityFrameworkCore'..." then type:
"dotnet add package Microsoft.EntityFrameworkCore" (and probably Microsoft.EntityFrameworkCore.Design) into a terminal to fix the dependency issues.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@jmoral4 thanks for the tip. I'll get this added next update.
Why I do step by step same as the tutorials
but when Register the database context
the UseSqlite always red
and
dotnet ef migrations add InitialCreate
dotnet ef database update
always Build failed
@nlpsl202 you are missing an include. You can't do a migration if the project doesn't build.
It's missing a step:
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
Also I had to put in the cli tools rather than just a package reference.
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
I really don't understand why the dataContext is required in order to scaffold pages. What we use repository that uses web service as backing store?
i had to run at least:
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
in order to get this to build
I keep getting the error below:
An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.
Generated Code
One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.
The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
+
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(RazorPagesMovie.Pages.Index_Page), @"mvc.1.0.razor-page", @"/Pages/Index.cshtml")]
The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
+
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"472eba6082c4cfd9087bb1b0a55099908614d006", @"/Pages/Index.cshtml")]
The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
+
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5bffd98f02597e6a09295a2131188dc64093be78", @"/Pages/_ViewImports.cshtml")]
When I try to run the update databse command I get:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught)
Fixed in unified version
Most helpful comment
Also I had to put in the cli tools rather than just a package reference.