Created
May 11, 2018 12:22
-
-
Save icebeam7/5c15e4c2bc772ff7c18997071430e518 to your computer and use it in GitHub Desktop.
SistemaEscolar: BaseDatos.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Xamarin.Forms; | |
using Microsoft.EntityFrameworkCore; | |
using SistemaEscolar.Modelos; | |
namespace SistemaEscolar.Datos | |
{ | |
public class BaseDatos : DbContext | |
{ | |
public DbSet<Escuela> Escuelas { get; set; } | |
public DbSet<Alumno> Alumnos { get; set; } | |
private readonly string rutaBD; | |
public BaseDatos(string rutaBD) | |
{ | |
this.rutaBD = rutaBD; | |
Database.EnsureCreated(); | |
} | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ | |
var dbPath = DependencyService.Get<IBaseDatos>().GetDatabasePath(); | |
optionsBuilder.UseSqlite($"Filename={dbPath}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment