static void Main(string[] args) { Context context = new Context(); // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // //Compositor comp1 = new Compositor() { Name = "Trofimenko" }; //context.Compositor.Add(comp1); //context.Song.Add(new Song() { SongName = "Hi", Compositor = comp1, Genre = "Jazz" }); //context.Song.Add(new Song() { SongName = "Bye", Compositor = comp1, Genre = "Jazz" }); //context.Song.Add(new Song() { SongName = "Hey", Compositor = comp1, Genre = "Jazz" }); //context.SaveChanges(); var query = from a in context.Compositor select a.Name.Contains("T"); foreach (var item in query) { Console.WriteLine(item.ToString()); } Console.WriteLine(); }
static void Main(string[] args) { // Context db = new Context(ConfigurationManager.ConnectionStrings["ConnectionCarList"].ConnectionString); string CS = @"data source=(localdb)\v11.0;AttachDBFileName=D:\daa\First.mdf;Integrated Security=true;"; Context db = new Context(CS); Car car = new Car() { Name = "BMW", Fuel = 50, Url = "car_url" }; db.Cars.Add(car); db.SaveChanges(); foreach (var item in db.Cars) { Console.WriteLine("{0}{1}", item.Name, item.Fuel); } Console.ReadKey(); }