Now what we are going to do is create a new model, invoice, which will contain information about sales of our system, and will also allow us to save a reference to a user of the AspNetUsers table: If you just created the project, do an add-migration in the Package Manager Console in Visual Studio: The first thing we need is an ASP.NET project with an individual user account. In this post I will use: Visual Studio 2017 Community Edition, ASP.NET Core 2.0 and Entity Framework Core 2.0. We can make the relation of the AspNetUsers table with any other table of our application. When we create an ASP.NET application with the individual user account system by default, then the AspNetUsers table will contain our users. So, if we have a table of invoices and a table of customers, then we can have a relationship between these two tables, so that in the table of invoices we have a field, ClientId, which contains a reference to our client in the customer’s table. This is important because it allows us to avoid repeating information. It is very easy to use navigational properties to create foreign keys and be able to relate one table to another. With Entity Framework we can create relationships between our tables.
0 Comments
Leave a Reply. |