Projekt

Obecné

Profil

Stáhnout (1.54 KB) Statistiky
| Větev: | Tag: | Revize:
1
using Core.Entities;
2
using Microsoft.EntityFrameworkCore;
3
using System;
4
using System.Collections.Generic;
5
using System.Linq;
6
using System.Text;
7
using System.Threading.Tasks;
8

    
9
namespace Core.Contexts
10
{
11
    public class DatabaseContext : DbContext
12
    {
13
        public DbSet<DocumentContent> DocumentContents { get; set; }
14
        public DbSet<Document> Documents { get; set; }
15
        public DbSet<User> Users { get; set; }
16
        public DbSet<Annotation> Annotations { get; set; }
17
        public DbSet<Class> Classes { get; set; }
18
        //public DbSet<AnnotationClass> AnnotationsClasses { get; set; }
19
        public DbSet<AnnotationTag> AnnotationTags { get; set; }
20
        public DbSet<Tag> Tags { get; set; }
21
        public DbSet<SubTag> SubTags { get; set; }
22
        public DbSet<TagCategory> TagCategories { get; set; }
23

    
24
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
25
        {
26
            optionsBuilder.UseNpgsql("Host=localhost:5432;Database=dbo;Username=myuser;Password=password", b => b.MigrationsAssembly("RestAPI"));
27
        }
28

    
29
        protected override void OnModelCreating(ModelBuilder modelBuilder)
30
        {
31
          /*  modelBuilder.Entity<AnnotationClass>()
32
                .HasOne(ac => ac.Annotation)
33
                .WithMany(a => a.Classes)
34
                .HasForeignKey(ac => ac.AnnotationId);
35
            modelBuilder.Entity<AnnotationClass>()
36
                .HasOne(ac => ac.Class)
37
                .WithMany(c => c.Annotations)
38
                .HasForeignKey(ac => ac.ClassId);*/
39
        }
40
    }
41
}
    (1-1/1)