EntityFramework - complete model?

Hi,
all the samples online appear to use in-memory objects. Some example have plain-vanilla classes that simply define strings etc for any text - however that'd generate quite a bit of data overhead (nvarchar(max) for every text field etc). Also I am unable to find any definition of what string length etc may be required for e.g. the recurrence rules and so on.

Does anyone have a working sample that generates sensible data structures and reads/persists calendar data through EF? That'd be a great start.

Thank you very much
Stefan

1 Reply

NR Nevitha Ravi Syncfusion Team October 30, 2017 11:11 AM UTC

Hi Stefan, 

Thank you for contacting Syncfusion Support. 

There is no predefined string length for appointment fields. RecurrenceRule initially may have minimum characters but if we edit two or more of its occurrences, recurrence rule length will be increased like Subject, Description and Location. Due to this dynamic behavior, it is always recommended to set maximum length (nvarchar(max)). We have prepared a CRUD sample for your reference which can be downloaded from the below location. 


In model: 
using System; 
using Microsoft.EntityFrameworkCore; 
using System.ComponentModel.DataAnnotations; 
using System.Collections.Generic; 
  
namespace Schedule.Model 
{ 
    public partial class ScheduleDataContext : DbContext 
    { 
        public ScheduleDataContext(DbContextOptions<ScheduleDataContext> options) 
            : base(options) 
        { } 
  
        protected override void OnModelCreating(ModelBuilder modelBuilder) 
        { 
            modelBuilder.Entity<DefaultSchedule>(entity => 
            { 
                entity.Property(e => e.Id).IsRequired(); 
            }); 
  
        } 
        public virtual DbSet<DefaultSchedule> DefaultSchedule { get; set; } 
    }  
 

In controller: 
private ScheduleDataContext _context; 
        public IActionResult Index() 
        { 
            return View(); 
        } 
        public List<DefaultSchedule> GetData() 
        { 
  
            List<DefaultSchedule> datas = _context.DefaultSchedule.Take(500).ToList(); 
            return datas; 
        }  

Regards, 
Nevitha. 


Loader.
Up arrow icon