// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity; using System.Data.SQLite; using System.Linq; namespace DumpEFcode1st { [Table("t1")] public class T1 { [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] [Column("f1")] public long F1 { get; set; } [Column("f2")] public string F2 { get; set; } } public class MyDbContext : DbContext { public MyDbContext() : base("MYDB") { } public DbSet T1 { get; set; } } public class Program { public static List Get() { using(MyDbContext mydb = new MyDbContext()) { return mydb.T1.ToList(); } } public static void Main(string[] args) { foreach(T1 o in Get()) { Console.WriteLine("{0} {1}", o.F1, o.F2); } } } }