I create Database in visual studio as service-based Database after I make tables i tried to connect it to Model .edmx by choose update Model from Database now when I insert data to Model .edmx , it didn't insert it to Database how to make it insert data to Database by using Model and Thanks I am using Visual Studio 2010
some code:
private CoffeeShopDatabaseEntities1 cse = new CoffeeShopDatabaseEntities1();
private Byte[] bytedata;
public addproduct()
{
InitializeComponent();
cbocatgrey.DataSource = cse.TblProductType.ToList();
cbocatgrey.DisplayMember = "Descrption";
cbocatgrey.ValueMember = "ProductType";
}
private void upload_image_Click(object sender, EventArgs e)
{
DialogResult dlg = openFileDialog1.ShowDialog();
if (dlg == DialogResult.OK)
{
FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
bytedata = new Byte[fs.Length];
fs.Read(bytedata, 0, bytedata.Length);
fs.Close();
MemoryStream ms = new MemoryStream(bytedata);
pload.Image = Image.FromStream(ms);
}
}
private void save_Click(object sender, EventArgs e)
{
TblProduct product = new TblProduct();
product.Descrption = descrptiontxt.Text;
product.Price = decimal.Parse(pricetxt.Text);
product.Image = bytedata;
product.ProductType = (int)cbocatgrey.SelectedValue;
cse.AddtoTBlProduct(product);
cse.saveChanges();
}