Skip to content

Instantly share code, notes, and snippets.

@muratg
Created January 15, 2013 19:33
Show Gist options
  • Save muratg/4541318 to your computer and use it in GitHub Desktop.
Save muratg/4541318 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
namespace MyApplication
{
public class MyEntity
{
public int Id { get; set; }
public string Name { get; set; }
public static MyEntity CreateEntity()
{
return new MyEntity { Name = "Test - " + DateTime.Now };
}
}
public class MyCtx : DbContext
{
public MyCtx() { }
public DbSet<MyEntity> TestEntities { get; set; }
}
public static class MyTest
{
public static string SimpleWrite()
{
var entity = MyEntity.CreateEntity();
using (var db = new MyCtx())
{
db.TestEntities.Add(entity);
db.SaveChanges();
}
return "Saved entity " + entity.Name;
}
}
class Program
{
static void Main(string[] args)
{
MyTest.SimpleWrite();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment