Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SistemaEscolar: BaseDatos.cs
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.