PMC Commands for Migrations in EF Core

文章推薦指數: 80 %
投票人數:10人

... Core can be executed using the Package Manager Console in Visual Studio. ... Update-Database, Updates the database schema based on the last migration ... EFBasics EFCore EF6DB-First EF6Code-First FAQs EFQuiz EFResources CheatSheet More ✕ EntityFrameworkTutorials EFCore EF6Code-First EF6DB-First EntityFramework EFQuiz FAQs EFResources EFCheatSheet EFCore-Introduction EFCore-Installation EFCore-ExistingDatabase EFCore-DbContext EFCore-FirstApplication EFCore-Querying EFCore-SavingData EFCore-Conventions One-to-ManyConventions One-to-OneConventions EFCore-Configurations EFCore-FluentAPI ConfigureOne-to-ManyRelationship ConfigureOne-to-OneRelationship ConfigureMany-to-ManyRelationship DisconnectedScenario:InsertData UpdateData DeleteData ChangeTracker ShadowProperty WorkingwithDisconnectedEntityGraph TrackingEntityGraph RawSQLQueries WorkingwithStoredProcedure Logging Migration PMCCommands CLICommands Previous Next PackageManagerConsoleCommandsforMigrations MigrationcommandsinEntityFrameworkCorecanbeexecutedusingthePackageManagerConsoleinVisualStudio. OpenthePackageManagerConsolefrommenuTools->NuGetPackageManger->PackageManagerConsoleinVisualStudiotoexecutethefollowingcommands. PMCCommand Usage Get-Helpentityframework Displaysinformationaboutentityframeworkcommands. Add-Migration Createsamigrationbyaddingamigrationsnapshot. Remove-Migration Removesthelastmigrationsnapshot. Update-Database Updatesthedatabaseschemabasedonthelastmigrationsnapshot. Script-Migration GeneratesaSQLscriptusingallthemigrationsnapshots. Scaffold-DbContext GeneratesaDbContextandentitytypeclassesforaspecifieddatabase.Thisiscalledreverseengineering. Get-DbContext GetsinformationaboutaDbContexttype. Drop-Database Dropsthedatabase. Get-Help PM>get-helpentityframework _/\__ ---==/\\ ______|.\|\ |__||__||)\\\ |_||_|\_/|//|\\ |___||_|/\\\/\\ TOPIC about_EntityFrameworkCore SHORTDESCRIPTION ProvidesinformationabouttheEntityFrameworkCorePackageManagerConsoleTools. LONGDESCRIPTION ThistopicdescribestheEntityFrameworkCorePackageManagerConsoleTools. Seehttps://docs.efproject.netforinformationonEntityFrameworkCore. ThefollowingEntityFrameworkCorecommandsareavailable. CmdletDescription ----------------------------------------------------------------------------- Add-MigrationAddsanewmigration. Drop-DatabaseDropsthedatabase. Get-DbContextGetsinformationaboutaDbContexttype. Remove-MigrationRemovesthelastmigration. Scaffold-DbContextScaffoldsaDbContextandentitytypesforadatabase. Script-MigrationGeneratesaSQLscriptfrommigrations. Update-DatabaseUpdatesthedatabasetoaspecifiedmigration. SEEALSO Add-Migration Drop-Database Get-DbContext Remove-Migration Scaffold-DbContext Script-Migration Update-Database Add-Migration NAME Add-Migration SYNOPSIS Addsanewmigration. SYNTAX Add-Migration[-Name][-OutputDir][-Context][-Project] [-StartupProject][] DESCRIPTION Addsanewmigration. REMARKS Toseetheexamples,type:"get-helpAdd-Migration-examples". Formoreinformation,type:"get-helpAdd-Migration-detailed". Fortechnicalinformation,type:"get-helpAdd-Migration-full". Remove-Migration NAME Remove-Migration SYNOPSIS Removesthelastmigration. SYNTAX Remove-Migration[-Force][-Context][-Project][-StartupProject] [] DESCRIPTION Removesthelastmigration. RELATEDLINKS Add-Migration about_EntityFrameworkCore REMARKS Toseetheexamples,type:"get-helpRemove-Migration-examples". Formoreinformation,type:"get-helpRemove-Migration-detailed". Fortechnicalinformation,type:"get-helpRemove-Migration-full". Update-Database NAME Update-Database SYNOPSIS Updatesthedatabasetoaspecifiedmigration. SYNTAX Update-Database[[-Migration]][-Context][-Project] [-StartupProject][] DESCRIPTION Updatesthedatabasetoaspecifiedmigration. RELATEDLINKS Script-Migration about_EntityFrameworkCore REMARKS Toseetheexamples,type:"get-helpUpdate-Database-examples". Formoreinformation,type:"get-helpUpdate-Database-detailed". Fortechnicalinformation,type:"get-helpUpdate-Database-full". Script-migration NAME Script-Migration SYNOPSIS GeneratesaSQLscriptfrommigrations. SYNTAX Script-Migration[-From][-To][-Idempotent][-Output] [-Context][-Project][-StartupProject] [] Script-Migration[[-From]][-Idempotent][-Output][-Context] [-Project][-StartupProject][] DESCRIPTION GeneratesaSQLscriptfrommigrations. RELATEDLINKS Update-Database about_EntityFrameworkCore REMARKS Toseetheexamples,type:"get-helpScript-Migration-examples". Formoreinformation,type:"get-helpScript-Migration-detailed". Fortechnicalinformation,type:"get-helpScript-Migration-full". scaffold-dbcontext NAME Scaffold-DbContext SYNOPSIS ScaffoldsaDbContextandentitytypesforadatabase. SYNTAX Scaffold-DbContext[-Connection][-Provider][-OutputDir] [-Context][-Schemas][-Tables] [-DataAnnotations][-Force][-Project][-StartupProject] [] DESCRIPTION ScaffoldsaDbContextandentitytypesforadatabase. RELATEDLINKS about_EntityFrameworkCore REMARKS Toseetheexamples,type:"get-helpScaffold-DbContext-examples". Formoreinformation,type:"get-helpScaffold-DbContext-detailed". Fortechnicalinformation,type:"get-helpScaffold-DbContext-full". Get-DbContext NAME Get-DbContext SYNOPSIS GetsinformationaboutaDbContexttype. SYNTAX Get-DbContext[-Context][-Project][-StartupProject] [] DESCRIPTION GetsinformationaboutaDbContexttype. RELATEDLINKS about_EntityFrameworkCore REMARKS Toseetheexamples,type:"get-helpGet-DbContext-examples". Formoreinformation,type:"get-helpGet-DbContext-detailed". Fortechnicalinformation,type:"get-helpGet-DbContext-full". Drop-Database NAME Drop-Database SYNOPSIS Dropsthedatabase. SYNTAX Drop-Database[-Context][-Project][-StartupProject] [-WhatIf][-Confirm][] DESCRIPTION Dropsthedatabase. RELATEDLINKS Update-Database about_EntityFrameworkCore REMARKS Toseetheexamples,type:"get-helpDrop-Database-examples". Formoreinformation,type:"get-helpDrop-Database-detailed". Fortechnicalinformation,type:"get-helpDrop-Database-full". Previous Next FastestWaytoInsertusingEFExtensions LearnC#,MVC,ASP.NETCore,LINQ,etc.



請為這篇文章評分?