1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| public class Client
{
public int ClientID { get; set; }
public int? Action_typeID { get; set; }
public int? ObligationID { get; set; }
public virtual Action_type Action_types { get; set; }
public virtual Obligation Obligations { get; set; }
}
public class Obligation
{
public int ObligationID { get; set; }
public string Obligation_name { get; set; }
public int MaximumID { get; set; }
public virtual Maximum Maximums { get; set; }
}
public class Action_type
{
public int Action_typeID { get; set; }
public string Action_type_name { get; set; }
public int MaximumID { get; set; }
public virtual Maximum Maximums { get; set; }
}
public class Maximum
{
public int MaximumID { get; set; }
public int value_max { get; set; }
}
class ClientsContext : DbContext
{
public DbSet<Client> Clients { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Client>()
.HasOptional(f => f.Obligations)
.WithOptionalDependent()
.WillCascadeOnDelete(false);
}
}
class Program
{
static void Main(string[] args)
{
using (ClientsContext context = new ClientsContext())
{
Client client = new Client();
context.Clients.Add(client);
context.SaveChanges();
}
}
} |
Partager