how to add database in entity framework useing update code example
Example 1: entity save example in c# model first
using (var context = new BloggingContext())
{
context.Blogs.Add(new Blog { Url = "http://example.com/blog" });
context.Blogs.Add(new Blog { Url = "http://example.com/another_blog" });
context.SaveChanges();
}
using (var context = new BloggingContext())
{
context.Blogs.Add(new Blog { Url = "http://example.com/blog_one" });
context.Blogs.Add(new Blog { Url = "http://example.com/blog_two" });
var firstBlog = context.Blogs.First();
firstBlog.Url = "";
var lastBlog = context.Blogs.Last();
context.Blogs.Remove(lastBlog);
context.SaveChanges();
}
Example 2: entity save example in c# model first
using (var context = new BloggingContext())
{
var blog = context.Blogs.First();
context.Blogs.Remove(blog);
context.SaveChanges();
}