Reputation: 3945
Using asp.net mvc project I want to create a new ClientAccountAccess record.
private static void SetAccessCode(string guidCode)
{
using (EPOSEntities db = new EPOSEntities())
{
ClientAccountAccess client = new ClientAccountAccess();
client.GUID = guidCode;
db.SaveChanges();
}
}
//have also tried
//ClientAccountAccess client = new ClientAccountAccess()
//{
// GUID = guidCode
//};
//db.SaveChanges();
Wont seem to save a new record?
Upvotes: 1
Views: 51
Reputation: 7458
You need to add this record to context:
private static void SetAccessCode(string guidCode)
{
using (EPOSEntities db = new EPOSEntities())
{
ClientAccountAccess client = new ClientAccountAccess();
client.GUID = guidCode;
// ClientAccountAccess is name of your DBSet in context. It might be different
db.ClientAccountAccess.AddObject(client);
db.SaveChanges();
}
}
Here is more samples of basic CRUD operations - http://www.dotnetcurry.com/showarticle.aspx?ID=619
Upvotes: 4