mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-05-19 17:51:21 +00:00
32 lines
989 B
C#
32 lines
989 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using EntityFrameworkCore.Projectables.Extensions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using ReadmeSample.Entities;
|
|
|
|
namespace ReadmeSample
|
|
{
|
|
public class ApplicationDbContext : DbContext
|
|
{
|
|
public DbSet<User> Users { get; set; }
|
|
public DbSet<Product> Products { get; set; }
|
|
public DbSet<Order> Orders { get; set; }
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Database=ReadmeSample;Trusted_Connection=True");
|
|
optionsBuilder.UseProjectables();
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<OrderItem>().HasKey(x => new { x.OrderId, x.ProductId });
|
|
}
|
|
|
|
}
|
|
}
|