21 Next entity: Edition with Identity field (Wpf, Xamarin) - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki
According to the Database structure (https://github.com/chempkovsky/CS2WPF/wiki/05-database-structure-for-which-we-are-creating-the-application)
And according to the rules defined in the article "06 Development Process Cycle" (https://github.com/chempkovsky/CS2WPF/wiki/06-The-development-process-cycle)
we can start with any entity from the list: Edition, Genre, Country and Language
Let's continue with Edition
- Step #1:
- Run Visual Studio and Open “WpfDemo” solution
- Right Click “Literature” of the “Dm01Entity”-project
- Select “Add/Class” menu item
- In the dialog enter the name for the class
- LitEdition
- Click “Add”
- Run Visual Studio and Open “WpfDemo” solution
- Step #2:
- Open LitEdition file and modify the body of the class as it is shown on the slide
public class LitEdition
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Description = "Row id", Name = "Id of the edition", Prompt = "Enter Id of the edition", ShortName = "Edition Id")]
[Required]
public int EditionId { get; set; }
[Display(Description = "Name of the edition", Name = "Name of the edition", Prompt = "Enter the Name of the edition", ShortName = "Edition Name")]
[StringLength(40, MinimumLength = 3)]
public string EditionName { get; set; }
}
Note:
we have two new attributes
- [key] attribute
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)] attribute
It's highly recommended not to use [key] attribute. Use Fluent Api instead. CS2WPF wizards trust FluentApi more than [key] attribute.