Skip to content

Instantly share code, notes, and snippets.

@carloscds
Created July 3, 2018 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carloscds/191a42fd6370b307798e5852e7f1db48 to your computer and use it in GitHub Desktop.
Save carloscds/191a42fd6370b307798e5852e7f1db48 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.SqlServer;
using Microsoft.EntityFrameworkCore.Proxies;
namespace LazyLoading
{
public class Contexto : DbContext
{
public DbSet<Customers> Customers {get; set;}
public DbSet<Orders> Orders {get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var conexao = new SqlConnectionStringBuilder()
{
DataSource = "(local)",
InitialCatalog = "NorthWind",
IntegratedSecurity = true
};
optionsBuilder.UseSqlServer(conexao.ConnectionString);
optionsBuilder.UseLazyLoadingProxies();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment