Joining Information / Table | A and B Property Sets, One-To-Many Join

Dean Everhart 1,366 Reputation points
2023-05-19T11:59:52.4433333+00:00

Premise:

Two Tables - A and B - related with a one-to-many relationship.

The join table is not explicit... i.e. I didn't create it and it doesn't appear in the projects normal file folder structure / organization / hierarchy.

Question:

Where is, and how do I view / manipulate, the joining information / table?


Environment: Net Core 6 MVC, Visual Studio Community 2022 (64 bit), WIndows 11


A

namespace ViewModel.Models
{
    public class A
    {
        public int Id { get; set; }

        public string? One { get; set; }

        public string? Two { get; set; }

        public string? Three { get; set; }

        // _______________________________________

        public IEnumerable<B>? B { get; set; }

    }
}

B

namespace ViewModel.Models
{
    public class B
    {
        public int Id { get; set; }

        public string? One { get; set; }

        public string? Two { get; set; }

        public string? Three { get; set; }

        // _______________________________________

        public int? AId { get; set; }

        public A? A { get; set; }


    }
}

Context

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using ViewModel.Models;

namespace ViewModel.Data
{
    public class ViewModelContext : DbContext
    {
        public ViewModelContext (DbContextOptions<ViewModelContext> options)
            : base(options)
        {
        }

        public DbSet<ViewModel.Models.A> A { get; set; } = default!;

        public DbSet<ViewModel.Models.B>? B { get; set; }

    }
}
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
3,169 questions
ASP.NET MVC
ASP.NET MVC
A Microsoft web application framework that implements the model-view-controller (MVC) design pattern.
856 questions
{count} votes

Accepted answer
  1. AgaveJoe 22,796 Reputation points
    2023-05-19T15:00:40.6933333+00:00

    Do you want to view the schema in SQL Management studio?

    You need to know the name of your SQL instance which you can get from a connection string. Then simply connect to your database and view the schema. Maybe start with a tutorial to learn the basics.

    Tutorial: Getting Started with the Database Engine

    Once you're connected to the database you can view any table constraint, keys, etc..

    Capture

    There's also a Database diagram which shows joins graphically.

    If you need to download SSMS...

    Download SQL Server Management Studio (SSMS)

    0 comments No comments

0 additional answers

Sort by: Most helpful