ASP.NET Core
# รวมเนื้อหาที่เกี่ยวข้องกับ ASP.net Core
React
-
If
dotnet efhas not been installed, install it as a global tool:.NET CLICopy
dotnet tool install --global dotnet-efFor more information on the CLI for EF Core, see EF Core tools reference for .Net CLI.
Run the following .NET CLI commands:
.NET CLICopy
dotnet ef migrations add InitialCreate dotnet ef database updateef migrations add InitialCreate: Generates an _Migrations/{timestamp}InitialCreate.cs migration file. TheInitialCreateargument is the migration name. Any name can be used, but by convention, a name is selected that describes the migration. This is the first migration, so the generated class contains code to create the database schema. The database schema is based on the model specified in theMvcMovieContextclass, in the Data/MvcMovieContext.cs file.ef database update: Updates the database to the latest migration, which the previous command created. This command runs theUpmethod in the _Migrations/{time-stamp}InitialCreate.cs file, which creates the database.
EF CLI
dotnet add package Microsoft.EntityFrameworkCore.Designdotnet ef migrations add InitialCreate dotnet ef database updateYour startup project 'AuthorizeServer' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
SQLite
dotnet add package Microsoft.EntityFrameworkCore dotnet add package Microsoft.EntityFrameworkCore.Sqliteusing Microsoft.EntityFrameworkCore; public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"))); }Related Ref:
Get started with ASP.NET Core MVC