ASP.NET Web Deployment using Visual Studio - Microsoft Learn
文章推薦指數: 80 %
Deploy the database update · Open the Publish Web wizard by right-clicking the ContosoUniversity project and clicking Publish. · Select the Test ...
Skiptomaincontent
Thisbrowserisnolongersupported.
UpgradetoMicrosoftEdgetotakeadvantageofthelatestfeatures,securityupdates,andtechnicalsupport.
DownloadMicrosoftEdge
MoreinfoaboutInternetExplorerandMicrosoftEdge
Tableofcontents
Exitfocusmode
ReadinEnglish
Save
Tableofcontents
ReadinEnglish
Save
Edit
Print
Twitter
LinkedIn
Facebook
Email
Tableofcontents
ASP.NETWebDeploymentusingVisualStudio:DeployingaDatabaseUpdate
Article
07/21/2022
8minutestoread
8contributors
Inthisarticle
byTomDykstra
DownloadStarterProject
Thistutorialseriesshowsyouhowtodeploy(publish)anASP.NETwebapplicationtoAzureAppServiceWebAppsortoathird-partyhostingprovider,byusingVisualStudio2012orVisualStudio2010.Forinformationabouttheseries,seethefirsttutorialintheseries.
Overview
Inthistutorial,youmakeadatabasechangeandrelatedcodechanges,testthechangesinVisualStudio,thendeploytheupdatetothetest,staging,andproductionenvironments.
ThetutorialfirstshowshowtoupdateadatabasethatismanagedbyCodeFirstMigrations,andthenlateritshowshowtoupdateadatabasebyusingthedbDacFxprovider.
Reminder:Ifyougetanerrormessageorsomethingdoesn'tworkasyougothroughthetutorial,besuretocheckthetroubleshootingpage.
DeployadatabaseupdatebyusingCodeFirstMigrations
Inthissection,youaddabirthdatecolumntothePersonbaseclassfortheStudentandInstructorentities.Thenyouupdatethepagethatdisplaysinstructordatasothatitdisplaysthenewcolumn.Finally,youdeploythechangestotest,staging,andproduction.
Addacolumntoatableintheapplicationdatabase
IntheContosoUniversity.DALproject,openPerson.csandaddthefollowingpropertyattheendofthePersonclass(thereshouldbetwoclosingcurlybracesfollowingit):
[DisplayFormat(DataFormatString="{0:d}",ApplyFormatInEditMode=true)]
[Display(Name="BirthDate")]
publicDateTime?BirthDate{get;set;}
Next,updatetheSeedmethodsothatitprovidesavalueforthenewcolumn.OpenMigrations\Configuration.csandreplacethecodeblockthatbeginsvarinstructors=newListUserInformation
延伸文章資訊
- 1EF Core 工具參考(套件管理員主控台) - Microsoft Learn
Entity Framework Core Visual Studio 套件管理員主控台的參考指南. ... Script-DbContext; Script-Migration; Update...
- 2Compare And Update SQL Server Database Project With ...
In this article, you will learn how to create a SQL Server Database project using Visual Studio 2...
- 3PMC Commands for Migrations in EF Core
... Core can be executed using the Package Manager Console in Visual Studio. ... Update-Database,...
- 4(Day 13) Model和資料庫間的一致(目前版本的Entity Framework ...
Update-Database:可以指定Migration快照檔為參數,也可不指定任何參數。 ... 現在到Visual Studio來實作Migration,我們到[工具]-->[NuGet套...
- 5Update Database From Model Wizard - Overview
This article is relevant to entity models that utilize the deprecated Visual Studio integration o...