Created
April 28, 2018 14:24
-
-
Save icebeam7/41d9a659b249e0cb193422205849150b to your computer and use it in GitHub Desktop.
FaceLoginApp: 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 Microsoft.EntityFrameworkCore; | |
using Xamarin.Forms; | |
using FaceLoginApp.Modelos; | |
namespace FaceLoginApp.Datos | |
{ | |
public class BaseDatos : DbContext | |
{ | |
public DbSet<Usuario> Usuarios { 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