Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.EntityFrameworkCore;
- using System.Collections.Generic;
- namespace EFGetStarted.AspNetCore.NewDb.Models
- {
- public class BloggingContext : DbContext
- {
- public BloggingContext(DbContextOptions<BloggingContext> options)
- : base(options)
- { }
- public DbSet<Blog> Blogs { get; set; }
- public DbSet<Post> Posts { get; set; }
- }
- public class Blog
- {
- public int BlogId { get; set; }
- public string Url { get; set; }
- public List<Post> Posts { get; set; }
- }
- public class Post
- {
- public int PostId { get; set; }
- public string Title { get; set; }
- public string Content { get; set; }
- public int BlogId { get; set; }
- public Blog Blog { get; set; }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
- namespace EFGetStarted.AspNetCore.NewDb.Models
- {
- // Add profile data for application users by adding properties to the ApplicationUser class
- public class ApplicationUser : IdentityUser
- {
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore;
- using EFGetStarted.AspNetCore.NewDb.Models;
- namespace EFGetStarted.AspNetCore.NewDb.Data
- {
- public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
- {
- public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
- : base(options)
- {
- }
- protected override void OnModelCreating(ModelBuilder builder)
- {
- base.OnModelCreating(builder);
- // Customize the ASP.NET Identity model and override the defaults if needed.
- // For example, you can rename the ASP.NET Identity table names and more.
- // Add your customizations after calling base.OnModelCreating(builder);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement