As you build out a site using the code first approach, at some point you will most likely need to add an additional lookup field to a class. There are a couple of steps required above what’s automatically done for you by EF code first migrations to make things work happily. If you consider the
If you’re using LINQ to SQL as your data provider then you will need to add a few extra steps to utilise Data annotations with ASP.NET MVC. If you have created your own objects then you can append annotations such as [DisplayName(“This is the display name I want in the view”)] directly to the object
I needed to get a number of random records from a table. This is a very quick and easy mechanism to use and will work on any table. To load a specific number of random records change the .First() function to be .Take(x) replacing x with however many records you need.