Use "dotnet ef [command] --help" for more information about a command. Database. Usage: dotnet ef database [options] ...
Togglenavigation
LearnEntityFrameworkCore
YourguidetousingthelatestversionofMicrosoft'sObjectRelationalMapper
EFCoreNewsletter
Home
HowToGetEFCore
DbContext
AddingData
ModifyingData
DeletingData
ChangeTracker
DbSet
QueryingData
AddingData
ModifyingData
DeletingData
Model
FromExistingDatabase
ShadowProperties
Relationships
ManagingOneToManyRelationships
ReferentialConstraintActionOptions
Conventions
OneToManyRelationship
OneToOneRelationship
ManyToManyRelationship
Configuration
DataAnnotationAttributes
ColumnAttribute
ComplexTypeAttribute
ConcurrencyCheckAttribute
DatabaseGeneratedAttribute
ForeignKeyAttribute
IndexAttribute
InversePropertyAttribute
KeyAttribute
MaxLengthAttribute
NotMappedAttribute
RequiredAttribute
StringLengthAttribute
TableAttribute
TimestampAttribute
FluentApi
ModelConfiguration
PropertyConfiguration
HasAlternatekeyMethod
HasColumnNameMethod
HasColumnTypeMethod
HasComputedColumnSqlMethod
HasConstraintNameMethod
HasDataMethod
HasDefaultValueMethod
HasDefaultValueSqlMethod
HasDiscriminatorMethod
HasFieldMethod
HasForeignKeyMethod
HasIndexMethod
HasKeyMethod
HasManyMethod
HasMaxLengthMethod
HasOneMethod
HasQueryFilterMethod
HasValueMethod
Has/WithPattern
IgnoreMethod
IsConcurrencyTokenMethod
IsRequiredMethod
IsRowVersionMethod
OnDeleteMethod
ToTableMethod
ToViewMethod
TypeConfiguration
ValueGeneratedNeverMethod
ValueGeneratedOnAddMethod
ValueGeneratedOnAddOrUpdateMethod
WithManyMethod
WithOneMethod
OneToManyRelationshipConfiguration
OneToOneRelationshipConfiguration
ManyToManyRelationshipConfiguration
ConnectionStrings
Inheritance
TablePerHierarchy
Concurrency
Migrations
ModelSnapshot
SeedingData
Commands
CLICommands
PMCCommands
Walkthoughs
ASP.NETCoreMVCApplication
.NETCoreConsoleApplication
UsingAnExistingDatabase
RawSQL
DatabaseFirstAndEntityFrameworkCore
QueryTypes
LazyLoading
FastestEntityFrameworkExtensions
BulkInsert
BulkDelete
BulkUpdate
BulkMerge
CommandLineInterfacecommands
ThecurrentCLIcommandsaredetailedbelowforreference.Theyareaccessedusingyourcommandline/terminaltoolviathedotnetcommandusingtheefswitch.Thefulllistofcommandscanbeaccessedfromwithinthecommandlinebytypingdotnetef--help:
Usage:dotnetef[options][command]
Options:
--versionShowversioninformation
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
Commands:
databaseCommandstomanagethedatabase.
dbcontextCommandstomanageDbContexttypes.
migrationsCommandstomanagemigrations.
Use"dotnetef[command]--help"formoreinformationaboutacommand.
Database
Usage:dotnetefdatabase[options][command]
Options:
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
Commands:
dropDropsthedatabase.
updateUpdatesthedatabasetoaspecifiedmigration.
Use"database[command]--help"formoreinformationaboutacommand.
databasedrop
Usage:dotnetefdatabasedrop[options]
Options:
-f|--forceDon'tconfirm.
--dry-runShowwhichdatabasewouldbedropped,butdon'tdropit.
-c|--contextTheDbContexttouse.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
databaseupdate
Usage:dotnetefdatabaseupdate[arguments][options]
Arguments:
Thetargetmigration.If'0',allmigrationswillbereverted.Defaultstothelastmigration.
Options:
-c|--contextTheDbContexttouse.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
DbContext
Usage:dotnetefdbcontext[options][command]
Options:
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
Commands:
infoGetsinformationaboutaDbContexttype.
listListsavailableDbContexttypes.
scaffoldScaffoldsaDbContextandentitytypesforadatabase.
Use"dbcontext[command]--help"formoreinformationaboutacommand.
dbcontextinfo
Usage:dotnetefdbcontextinfo[options]
Options:
--jsonShowJSONoutput.
-c|--contextTheDbContexttouse.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
dbcontextlist
Usage:dotnetefdbcontextlist[options]
Options:
-e|--environmentTheenvironmenttouse.Ifomitted,"Development"isused.
--jsonUsejsonoutput.JSONiswrappedby'//BEGIN'and'//END'
-h|--helpShowhelpinformation
-v|--verboseEnableverboseoutput
dbcontextscaffold
Usage:dotnetefdbcontextscaffold[arguments][options]
Arguments:
Theconnectionstringtothedatabase.
Theprovidertouse.(E.g.Microsoft.EntityFrameworkCore.SqlServer)
Options:
-d|--data-annotationsUseattributestoconfigurethemodel(wherepossible).Ifomitted,onlythefluentAPIisused.
-c|--contextThenameoftheDbContext.
-f|--forceOverwriteexistingfiles.
-o|--output-dirThedirectorytoputfilesin.Pathsarerelativetotheprojectdirectory.
--schema...Theschemasoftablestogenerateentitytypesfor.
-t|--table...Thetablestogenerateentitytypesfor.
--jsonShowJSONoutput.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
Migrations
Usage:dotnetefmigrations[options][command]
Options:
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
Commands:
addAddsanewmigration.
listListsavailablemigrations.
removeRemovesthelastmigration.
scriptGeneratesaSQLscriptfrommigrations.
Use"migrations[command]--help"formoreinformationaboutacommand.
migrationsadd
Usage:dotnetefmigrationsadd[arguments][options]
Arguments:
Thenameofthemigration.
Options:
-o|--output-dirThedirectory(andsub-namespace)touse.Pathsarerelativetotheprojectdirectory.Defaultsto"Migrations".
--jsonShowJSONoutput.
-c|--contextTheDbContexttouse.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
migrationslist
Usage:dotnetefmigrationslist[options]
Options:
--jsonShowJSONoutput.
-c|--contextTheDbContexttouse.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
migrationsremove
Usage:dotnetefmigrationsremove[options]
Options:
-f|--forceDon'tchecktoseeifthemigrationhasbeenappliedtothedatabase.
--jsonShowJSONoutput.
-c|--contextTheDbContexttouse.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
migrationsscript
Usage:dotnetefmigrationsscript[arguments][options]
Arguments:
Thestartingmigration.Defaultsto'0'(theinitialdatabase).
Theendingmigration.Defaultstothelastmigration.
Options:
-o|--outputThefiletowritetheresultto.
-i|--idempotentGenerateascriptthatcanbeusedonadatabaseatanymigration.
-c|--contextTheDbContexttouse.
-p|--projectTheprojecttouse.
-s|--startup-projectThestartupprojecttouse.
--frameworkThetargetframework.
--configurationTheconfigurationtouse.
--msbuildprojectextensionspathTheMSBuildprojectextensionspath.Defaultsto"obj".
-e|--environmentTheenvironmenttouse.Defaultsto"Development".
-h|--helpShowhelpinformation
-v|--verboseShowverboseoutput.
--no-colorDon'tcolorizeoutput.
--prefix-outputPrefixoutputwithlevel.
Onthispage
CommandLineInterfacecommands
Database
DbContext
Migrations
LatestUpdates
PackageManagerConsoleCommands
CommandLineInterfacecommands
CommandsinEntityFrameworkCore
TheFluentAPIWithOneMethod
TheFluentAPIWithManyMethod
TheFluentAPIValueGeneratedOnAddOrUpdateMethod