Your controllers should look as shown below:Īll the views are automatically created for you by Visual Studio. (i.e., as shown in the below LocationsController is using Locations Model class).ĭo not forget to select the context Class we created “ LocationScheduelContext”.Įnsure all the other checkboxes are clicked as shown below and click Add. Now add Controllers to all your tables and make sure to select Controller with Views, using Entity Framework.Īdd Controllers as LocationsController, DaysController, TimesController, LanguageController and finally ScheduleController.Įnsure to select Correct Model Class that matches with the controller name. Public class LocationScheduleContext : DbContext My Schedules table has four composite keys.Īdd Locations, Days, Times, Languages and Schedule Table fields as shown below: I want to have a table where I can add a schedule for a location and I want to have the flexibility to change the schedule day, time and language. After a day of struggling, I came up with a very simple solution which I want to share with you in this article. I Googled a lot for a solution but I was not able to find any answers. I personally do not like to add surrogate keys to my composite key tables. With ASP.NET MVC, you cannot update a Primary Key in a table and it forces people with traditional database skills to adopt to introducing a surrogate key to their Composite key tables. There is a lot of debate online on how to handle Composite Keys when updating primary key values into the database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |