ASP.NET MVC

Fluent API Basic

Source: Mosh Hamedani 1. Table Name modelBuilder.Entity().Totable(“tbl_Course”); 2. Table Name and Schema modelBuilder.Entity().Totable(“tbl_Course”,”schema”); 3. Primary Keys modelBuilder.Entity().HasKey(t => t.ISBN); 4. Composite Keys modelBuilder.Entity().HasKey(t => new {t.OrderId, t.OrderItemId}); 5. Column Name modelBuilder.Entity() .Property(t => t.Name) .HasColumn(“sName”); 6. Column Type modelBuilder.Entity() .Property(t => t.Name) .HasColumnType(“varchar”); 7. Column Orders modelBuilder.Entity() .Property(t => t.Name) .HasColumnOrder(2); 8. Database Generated modelBuilder.Entity()… Continue reading Fluent API Basic

ASP.NET MVC

Data Annotation Entity Framework

Source: Mosh Hamedani 1. Table Name [Table(“tbl_Course”, Schema = “”)] public class Course 2. Column Names [Column(“sName”, TypeName=”varchar”)] public string Name {get; set;} 3. Primary Key [Key] DatabaseGenerated(DatabaseGeneratedOption.None)] public string ISBN {get; set;} Lưu ý: DatabaseGeneratedOption có 3 thuộc tính: None, Identity và Computed 4. Composite Keys public class OrderItem { [Key] [Column(Order=1)] public int OrderId… Continue reading Data Annotation Entity Framework

ASP.NET MVC · Uncategorized

Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on

Source: https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on   Getting Started Start by installing and running Visual Studio Express 2013 for Web or Visual Studio 2013. Install Visual Studio 2013 Update 3 or higher. For help with Dropbox, GitHub, Linkedin, Instagram, buffer, salesforce, STEAM, Stack Exchange, Tripit, twitch, Twitter, Yahoo and more, see this one stop guide.1 Note You must install Visual… Continue reading Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on