question

DeanEverhart avatar image
0 Votes"
DeanEverhart asked YijingSun-MSFT commented

ASP.net MVC project on Azure but old versions of properties and no data

I have a ASP.net MVC project deployed to Azure.

Website works and links in navigation bar navigate to MVC CRUD views in the url but there is no data.

Microsoft SQL Server Management Studio shows database structure with no data. on Azure. The columns / properties include past versions of properties from all the previous code-based migrations...so the properties / columns, though present on Azure, are not up-to-date.

I think my next step is to use drop create database when model changes or always to get current database properties and data up to Azure. I'm not exactly sure how to write the code for this. below is first unsuccessful attempt in context file.

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 // end default
 // using System.Data.Linq;     CreateDatabase
 // using System.Data;          CreateDatabase
 // using System.Data.Object;   CreateDatabase
 using alpha.Models;
 using System.Data.Entity;
 using System.Data.Entity.ModelConfiguration.Conventions;
    
 namespace alpha.Data
 {
     public class alphaContext : DbContext
     {
         public alphaContext() : base("alphaContext") // The name of the connection string is passed in to the constructor.
         {
             // Database.SetInitializer<alphaContext>(new CreateDatabaseAlways<alphaContext>());
         }
         public DbSet<item> items { get; set; }
    
         protected override void OnModelCreating(DbModelBuilder modelBuilder)
         {
             modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
         }
     }
 }



My notes including screen captures in a pdf



dotnet-aspnet-webpages
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @DeanAndrewEverhart-9294 ,

I suggest you could create a single database on Azure sql database. And you could clean your resources. More detaials,you could refer to below article:https://docs.microsoft.com/en-us/azure/azure-sql/database/single-database-create-quickstart?tabs=azure-portal

0 Votes 0 ·

Database, server, service, and resource group are already all created on Azure.

From my question above...

Website works and links in navigation bar navigate to MVC CRUD views in the url but there is no data.

Microsoft SQL Server Management Studio shows database structure with no data on Azure.

. . . the database has already been created.

Thank you for your response. Any other ideas would be appreciated.

0 Votes 0 ·

Hi @DeanAndrewEverhart-9294 ,

About the DropCreateDatabaseAlways,you could refer to below thread link.


0 Votes 0 ·

1 Answer

DeanEverhart avatar image
0 Votes"
DeanEverhart answered

Answer: Re: DropCreateDatabaseAlways

DropCreateDatabaseAlways updated the data schema anew, but did not upload data (which is what, I've learned, it's suppose to do). So, strictly speaking, DropCreateDatabaseAlways, did not solve the problem of getting existing local data to Azure

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.