Add sqlite database

This commit is contained in:
2020-02-29 18:45:10 +01:00
parent c6adfbf715
commit a982b15cbe
5 changed files with 20 additions and 5 deletions

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@ bin/
obj/
/packages/
*.blob
.idea/
.idea/
*.db

View File

@@ -7,10 +7,16 @@ namespace EstusShots.Server.Services
{
public EstusShotsContext(DbContextOptions options) : base(options)
{
ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
Database.EnsureCreated();
}
public DbSet<Season> Seasons { get; set; } = default!;
public DbSet<Episode> Episodes { get; set; } = default!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Season>().ToTable(nameof(Season));
modelBuilder.Entity<Episode>().ToTable(nameof(Episode));
}
}
}

View File

@@ -25,7 +25,11 @@ namespace EstusShots.Server
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<EstusShotsContext>(
opt => opt.UseInMemoryDatabase("debug.db"));
opt =>
{
opt.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
opt.UseSqlite(Configuration.GetConnectionString("Sqlite"));
});
services.AddAutoMapper(typeof(Startup));
services.AddControllers().AddJsonOptions(options =>
{
@@ -57,6 +61,7 @@ namespace EstusShots.Server
{
app.UseHttpsRedirection();
}
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
@@ -69,7 +74,6 @@ namespace EstusShots.Server
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
}

View File

@@ -6,5 +6,8 @@
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {
"Sqlite": "DataSource=debug.db;"
},
"AllowedHosts": "*"
}

View File

@@ -1,3 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=dtos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Estus/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Estus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Sqlite/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>