Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

ef core save keyless entity

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<ConfigTemplate>(entity =>
    {
         // Adding the key itself, using the index name as well
         entity.HasKey(e => e.primary_key)
               .HasName("PRIMARY");

         // Adding the index definition is not a required
         entity.HasIndex(e => e.primary_key)
               .HasName("PRIMARY");

         entity.ToTable("config_template");
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ef #core #save #keyless #entity
ADD COMMENT
Topic
Name
4+8 =