TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
suman goud
NA
176
54.1k
How to fix model backing error while inserting data in mvc4
Aug 4 2016 7:02 AM
am getting following error when am inserting data
The model backing the 'ReceiptsDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database
mymodel
public class Transaction_GeneralInfo
{
[Key]
public string CompanyName { get; set; }
public int VNumber { get; set; }
}
public class Accounting_PendingBills
{
[Key]
public String Branch { get; set; }
public string Currency { get; set; }
public string CompanyName { get; set; }
}
public class ReceiptsViewModel
{
public String Branch { get; set; }
public string Currency { get; set; }
public int VNumber { get; set; }
public string CompanyName { get; set; }
}
public class ReceiptsDbContext : DbContext
{
public DbSet<Accounting_PendingBills> pendings { get; set; }
public DbSet<Transaction_GeneralInfo> transactionGeneralInfo { get; set; }
}
public ActionResult Index(ReceiptsViewModel receiptsModel, string Command)
{
if (Command == "Save")
{
ReceiptsDbContext db = new ReceiptsDbContext();
var transaction = new Transaction_GeneralInfo()
{
CompanyName = receiptsModel.CompanyName,
VNumber = receiptsModel.VNumber
};
var pending = new Accounting_PendingBills()
{
Branch = receiptsModel.Branch,
Currency = receiptsModel.Currency,
CompanyName = receiptsModel.CompanyName
};
db.transactionGeneralInfo.Add(transaction);
db.pendings.Add(pending);
db.SaveChanges();
}
Reply
Answers (
4
)
Multi Language using Speech Synthesizer
Right click on a link ,does't show option to open in new tab