C#
В файле Program.cs напишем код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
namespace ConsoleApplication1
{
public class Book
{
public int Id { get; set; }
public string Name { get; set; }
public int Price { get; set; }
}
class UserContext : DbContext
{
public UserContext() : base("MyConnection1")
{ }
public DbSet<Book> Books { get; set; }
}
class Program
{
static void Main(string[] args)
{
// create context
using (UserContext db = new UserContext())
{
// перебираем данные из базы данных
foreach (var item in db.Books)
{
// показываем данные
Console.WriteLine(item.Name);
}
}
}
}
}