question

BloomingDeveloper-9086 avatar image
0 Votes"
BloomingDeveloper-9086 asked AgaveJoe edited

multiple table structure to single model class in razor pages

Hi ,

I have a form which collects quite a large amount of data.
Thought of storing the data in multiple tables with a unique key.
Is it possible to design a single model class which includes other table definitions in razor pages.
any help would be appreciated.

Thanks.

dotnet-aspnet-core-razor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AgaveJoe avatar image
0 Votes"
AgaveJoe answered AgaveJoe edited

Is it possible to design a single model class which includes other table definitions in razor pages.

Yes, in Entity Framework the relationships are called navigation properties.

Relationships, navigation properties, and foreign keys

In general, the design is a class with a collection property.

 public class WidgetCategory
 {
     public int Id { get; set; }
     public List<Widget> Widgets { get; set;}
 }
    
 public class Widget
 {
     public int Id { get; set; }
     public string Name { get; set; }
 }

Keep in mind, this type of information is covered in every beginning level ASP.NET Core tutorial.

Razor Pages with Entity Framework Core in ASP.NET Core - Tutorial 1 of 8

If you have a specific issue or the information above does not answer your question, then share code that illustrates the problem you are trying to solve and the expected results.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.