Skip to content

Instantly share code, notes, and snippets.

@AlbertoMonteiro
Created July 18, 2014 11:18
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 AlbertoMonteiro/1f0f0db163a4d1877633 to your computer and use it in GitHub Desktop.
Save AlbertoMonteiro/1f0f0db163a4d1877633 to your computer and use it in GitHub Desktop.
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
using (var ctx = new Ctx())
{
var contaAReceber = new ContaAReceber();
contaAReceber.Valor = 100;
contaAReceber.NFSe = new NotaFiscalEletronicaServico();
contaAReceber.NFSe.Valor = 200;
ctx.ContaARecebers.Add(contaAReceber);
ctx.SaveChanges();
}
}
}
public class Ctx : DbContext
{
public DbSet<ContaAReceber> ContaARecebers { get; set; }
public DbSet<NotaFiscalEletronicaServico> NotaFiscalEletronicaServicos { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
base.OnModelCreating(modelBuilder);
}
}
public class ContaAReceber
{
public int Id { get; set; }
public decimal Valor { get; set; }
public NotaFiscalEletronicaServico NFSe { get; set; }
}
public class NotaFiscalEletronicaServico
{
public int Id { get; set; }
public decimal Valor { get; set; }
public ContaAReceber ContaAReceber { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment