Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data.Entity;
- using System.Data.Entity.ModelConfiguration.Conventions;
- using FEF.Helper;
- using Rent_aCar_TravelAgency.Models;
- namespace FEF.Data
- {
- class MojContext : DbContext
- {
- public MojContext() : base("Name=MojConnectionString")
- {
- }
- public DbSet<Grad> Gradovi { set; get; }
- public DbSet<Korisnik> Korisnici { set; get; }
- public DbSet<Opstina> Opstine { set; get; }
- public DbSet<Ponuda> Ponude { set; get; }
- public DbSet<Putovanje> Putovanja { set; get; }
- public DbSet<PutovanjeDetalji> PutovanjaDetalji { set; get; }
- public DbSet<Rezervacija> Rezervacije { set; get; }
- public DbSet<Servisi> Servisi { set; get; }
- public DbSet<Status> Statusi { set; get; }
- public DbSet<Ucinak> Ucinci { set; get; }
- public DbSet<Uloga> Uloge { set; get; }
- public DbSet<Uplata> Uplate { set; get; }
- public DbSet<Utisak> Utisci { set; get; }
- public DbSet<Vozac> Vozaci { set; get; }
- public DbSet<Vozilo> Vozila { set; get; }
- public DbSet<VozilaKategorije> VozilaKategorije { set; get; }
- public DbSet<Zaposlenik> Zaposlenici { set; get; }
- protected override void OnModelCreating(DbModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- modelBuilder.Entity<Korisnik>().HasOptional(x => x.Zaposlenik).WithRequired(x => x.Korisnik);
- modelBuilder.Entity<Korisnik>().HasOptional(x => x.Vozac).WithRequired(x => x.Korisnik);
- //modelBuilder.Entity<Opstine>().HasOptional(x => x.Gradovi).WithRequired(x => x.GradID);
- //one-to-(zero or one)
- //modelBuilder.Entity<Korisnik>().HasOptional(x => x.Student).WithRequired(x => x.Korisnik);
- //modelBuilder.Entity<Korisnik>().HasOptional(x => x.Nastavnik).WithRequired(x => x.Korisnik);
- //modelBuilder.Entity<Korisnik>().HasOptional(x => x.Referent).WithRequired(x => x.Korisnik);
- //many-to-one
- //modelBuilder.Entity<Smjer>().HasRequired(x => x.Fakultet).WithMany().HasForeignKey(x=>x.FakultetId);
- //modelBuilder.Entity<UpisGodine>().HasRequired(x => x.Student).WithMany().HasForeignKey(x=>x.StudentId);
- //modelBuilder.Entity<UpisGodine>().HasRequired(x => x.AkademskaGodina).WithMany().HasForeignKey(x=>x.AkademskaGodinaId);
- //http://blogs.msdn.com/b/adonet/archive/2010/12/14/ef-feature-ctp5-fluent-api-samples.aspx
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement