May 2019
Intermediate to advanced
504 pages
11h 50m
English
Entity Framework Core combines the years of accumulated ORM structure with SQLite support, making it a strong candidate for local storage implementations. Similar to the classic .NET version of Entity Framework, data contexts can be created and queried using the UseSqlite extension with a file path for DbContextOptionsBuilder:
public class AuctionsDatabaseContext : DbContext { public DbSet<Auction> Auctions { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var dbPath = string.Empty; switch (Device.RuntimePlatform) { case Device.Android: dbPath = Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments), "Auctions.db"); // removed for brevity } optionsBuilder.UserSqlite($"Filename={dbPath}); ...Read now
Unlock full access