I am fairly new to Entity Framework and C#, so I apologize if my ability to describe the problem is minimal.
I have a .NET Web Forms project hosted on Azure that uses Entity Framework to handle all the database tables. I recently had an issue that I was debugging and I created test records, which I removed once the issue was solved using Microsoft SQL Server Management Studio. Unfortunately, I now get the following error:
"The model backing the 'RegSysContext' context has changed since the database was created. Consider using Code First Migrations to update the database"
The RegSysContext class can be seen below.
From what I understand, this is caused by the metadata that Entity Framework uses not matching the database anymore. The data in the database is essential to keep, otherwise I would just wipe it and forget about it.
How can I solve this issue on the hosted web app, and how can I edit the database in the future without causing this problem?
Thanks in advance!
public class RegSysContext : DbContext
{
// Default Constructor for the context class
public RegSysContext() : base("RegSys")
{
}
// Properties of the context class
public DbSet<CustomerAccountMembership> AccountMembershipRecords { get; set; }
// For Organization Account functionality
public DbSet<RegSysAccount> RegSysAccounts { get; set; }
public DbSet<Subscription> Subscriptions { get; set; }
public DbSet<SubscriptionRecord> SubscriptionRecords { get; set; }
public DbSet<PaymentInfo> PaymentAccountInfoRecords { get; set; }
// For Auction functionality
public DbSet<Auction> auctions { get; set; }
public DbSet<AuctionItem> auctionItems { get; set; }
public DbSet<AuctionLot> auctionLots { get; set; }
public DbSet<AuctionDonation> auctionDontations { get; set; }
public DbSet<AuctionSale> auctionSales { get; set; }
public DbSet<ItemInAuctionRecord> itemInAuctionRecords { get; set; }
// For Event functionality
public DbSet<Event> events { get; set; }
public DbSet<EventParticipant> eventParticipants { get; set; }
public DbSet<RegistrationPeriod> registrationPeriods { get; set; }
public DbSet<RegType> regTypes { get; set; }
public DbSet<RegPrice> regPrices { get; set; }
public DbSet<EventCategory> EventCategories { get; set; }
//public DbSet<RegistrationConfig> regConfigs { get; set; }
//public DbSet<RegFormConfig> regFormConfigs { get; set; }
// For Organization functionality
public DbSet<Lodge> Lodges { get; set; }
// For Participant functionality
public DbSet<Participant> Participants { get; set; }
public DbSet<Charge> Charges { get; set; }
public DbSet<EventParticipantToParticipantLinker> EventParticipantLinks { get; set; }
// For System functionality
public DbSet<RegSysMessage> RegSysMessages { get; set; }
public DbSet<Transaction> Transactions { get; set; }
// For Trading Post functionality
public DbSet<Category> Categories { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<CartItem> ShoppingCartItems { get; set; }
public DbSet<ProductInventory> ProductInventories { get; set; }
public DbSet<TradingPost> TradingPosts { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<OrderDetail> OrderDetails { get; set; }
public DbSet<ProductSale> ProductSales { get; set; }
public DbSet<SpecialOffer> SpecialOffers { get; set; }
}