update references. move db scratch pad into test
This commit is contained in:
parent
9372571370
commit
6ed4eb34bd
@ -5,8 +5,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CsvHelper" Version="16.0.0" />
|
<PackageReference Include="CsvHelper" Version="27.0.2" />
|
||||||
<PackageReference Include="NPOI" Version="2.5.1" />
|
<PackageReference Include="NPOI" Version="2.5.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -12,13 +12,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.5">
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@ -56,7 +56,8 @@ namespace DataLayer
|
|||||||
modelBuilder.ApplyConfiguration(new SeriesBookConfig());
|
modelBuilder.ApplyConfiguration(new SeriesBookConfig());
|
||||||
modelBuilder.ApplyConfiguration(new CategoryConfig());
|
modelBuilder.ApplyConfiguration(new CategoryConfig());
|
||||||
|
|
||||||
// seeds go here. examples in scratch pad
|
// seeds go here. examples in Dinah.EntityFrameworkCore.Tests\DbContextFactoryExample.cs
|
||||||
|
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.Entity<Category>()
|
.Entity<Category>()
|
||||||
.HasData(Category.GetEmpty());
|
.HasData(Category.GetEmpty());
|
||||||
|
|||||||
@ -6,9 +6,6 @@ namespace DataLayer
|
|||||||
public class LibationContextFactory : DesignTimeDbContextFactoryBase<LibationContext>
|
public class LibationContextFactory : DesignTimeDbContextFactoryBase<LibationContext>
|
||||||
{
|
{
|
||||||
protected override LibationContext CreateNewInstance(DbContextOptions<LibationContext> options) => new LibationContext(options);
|
protected override LibationContext CreateNewInstance(DbContextOptions<LibationContext> options) => new LibationContext(options);
|
||||||
protected override void UseDatabaseEngine(DbContextOptionsBuilder optionsBuilder, string connectionString) => optionsBuilder
|
protected override void UseDatabaseEngine(DbContextOptionsBuilder optionsBuilder, string connectionString) => optionsBuilder.UseSqlite(connectionString);
|
||||||
//.UseSqlServer
|
|
||||||
.UseSqlite
|
|
||||||
(connectionString);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,122 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Dinah.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace _scratch_pad
|
|
||||||
{
|
|
||||||
////// to use this as a console, open properties and change from class library => console
|
|
||||||
//// DON'T FORGET TO REVERT IT
|
|
||||||
//public class Program
|
|
||||||
//{
|
|
||||||
// public static void Main(string[] args)
|
|
||||||
// {
|
|
||||||
// var user = new Student() { Name = "Dinah Cheshire" };
|
|
||||||
// var udi = new UserDef { UserDefId = 1, TagsRaw = "my,tags" };
|
|
||||||
|
|
||||||
// using var context = new MyTestContextDesignTimeDbContextFactory().Create();
|
|
||||||
// context.Add(user);
|
|
||||||
// //context.Add(udi);
|
|
||||||
// context.Update(udi);
|
|
||||||
// context.SaveChanges();
|
|
||||||
|
|
||||||
// Console.WriteLine($"Student was saved in the database with id: {user.Id}");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public class MyTestContextDesignTimeDbContextFactory : DesignTimeDbContextFactoryBase<MyTestContext>
|
|
||||||
{
|
|
||||||
protected override MyTestContext CreateNewInstance(DbContextOptions<MyTestContext> options) => new MyTestContext(options);
|
|
||||||
protected override void UseDatabaseEngine(DbContextOptionsBuilder optionsBuilder, string connectionString) => optionsBuilder.UseSqlite(connectionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MyTestContext : DbContext
|
|
||||||
{
|
|
||||||
// see DesignTimeDbContextFactoryBase for info about ctors and connection strings/OnConfiguring()
|
|
||||||
public MyTestContext(DbContextOptions<MyTestContext> options) : base(options) { }
|
|
||||||
|
|
||||||
#region classes for OnModelCreating() seed example
|
|
||||||
class Blog
|
|
||||||
{
|
|
||||||
public int BlogId { get; set; }
|
|
||||||
public string Url { get; set; }
|
|
||||||
public System.Collections.Generic.ICollection<Post> Posts { get; set; }
|
|
||||||
}
|
|
||||||
class Post
|
|
||||||
{
|
|
||||||
public int PostId { get; set; }
|
|
||||||
public string Content { get; set; }
|
|
||||||
public string Title { get; set; }
|
|
||||||
public int BlogId { get; set; }
|
|
||||||
public Blog Blog { get; set; }
|
|
||||||
public Name AuthorName { get; set; }
|
|
||||||
}
|
|
||||||
class Name
|
|
||||||
{
|
|
||||||
public string First { get; set; }
|
|
||||||
public string Last { get; set; }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
base.OnModelCreating(modelBuilder);
|
|
||||||
|
|
||||||
// config
|
|
||||||
modelBuilder.Entity<Blog>(entity => entity.Property(e => e.Url).IsRequired());
|
|
||||||
modelBuilder.Entity<Order>().OwnsOne(p => p.OrderDetails, cb =>
|
|
||||||
{
|
|
||||||
cb.OwnsOne(c => c.BillingAddress);
|
|
||||||
cb.OwnsOne(c => c.ShippingAddress);
|
|
||||||
});
|
|
||||||
modelBuilder.Entity<Post>(entity =>
|
|
||||||
entity
|
|
||||||
.HasOne(d => d.Blog)
|
|
||||||
.WithMany(p => p.Posts)
|
|
||||||
.HasForeignKey("BlogId"));
|
|
||||||
|
|
||||||
// BlogSeed
|
|
||||||
modelBuilder.Entity<Blog>().HasData(new Blog { BlogId = 1, Url = "http://sample.com" });
|
|
||||||
|
|
||||||
// PostSeed
|
|
||||||
modelBuilder.Entity<Post>().HasData(new Post() { BlogId = 1, PostId = 1, Title = "First post", Content = "Test 1" });
|
|
||||||
|
|
||||||
// AnonymousPostSeed
|
|
||||||
modelBuilder.Entity<Post>().HasData(new { BlogId = 1, PostId = 2, Title = "Second post", Content = "Test 2" });
|
|
||||||
|
|
||||||
// OwnedTypeSeed
|
|
||||||
modelBuilder.Entity<Post>().OwnsOne(p => p.AuthorName).HasData(
|
|
||||||
new { PostId = 1, First = "Andriy", Last = "Svyryd" },
|
|
||||||
new { PostId = 2, First = "Diego", Last = "Vega" });
|
|
||||||
}
|
|
||||||
|
|
||||||
public DbSet<Student> Students { get; set; }
|
|
||||||
public DbSet<UserDef> UserDefs { get; set; }
|
|
||||||
public DbSet<Order> Orders { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Student
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
public class UserDef
|
|
||||||
{
|
|
||||||
public int UserDefId { get; set; }
|
|
||||||
public string TagsRaw { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Order
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public OrderDetails OrderDetails { get; set; }
|
|
||||||
}
|
|
||||||
public class OrderDetails
|
|
||||||
{
|
|
||||||
public StreetAddress BillingAddress { get; set; }
|
|
||||||
public StreetAddress ShippingAddress { get; set; }
|
|
||||||
}
|
|
||||||
public class StreetAddress
|
|
||||||
{
|
|
||||||
public string Street { get; set; }
|
|
||||||
public string City { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"LibationContext_sqlserver": "Server=(LocalDb)\\MSSQLLocalDB;Database=DataLayer.LibationContext;Integrated Security=true;",
|
|
||||||
|
|
||||||
"// this connection string is ONLY used for DataLayer's Migrations. this appsettings.json file is NOT used at all by application; it is overwritten": "",
|
"// this connection string is ONLY used for DataLayer's Migrations. this appsettings.json file is NOT used at all by application; it is overwritten": "",
|
||||||
"LibationContext": "Data Source=LibationContext.db;Foreign Keys=False;",
|
"LibationContext": "Data Source=LibationContext.db;Foreign Keys=False;"
|
||||||
|
|
||||||
"// sqlite notes": "",
|
|
||||||
"// absolute path example": "Data Source=C:/foo/bar/sample.db",
|
|
||||||
"// relative path example": "Data Source=sample.db",
|
|
||||||
"// on windows: sqlite paths accept windows and/or unix slashes": "",
|
|
||||||
"MyTestContext": "Data Source=%DESKTOP%/sample.db"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,7 +5,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Polly" Version="7.2.1" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
|
||||||
|
<PackageReference Include="Octokit" Version="0.50.0" />
|
||||||
|
<PackageReference Include="Polly" Version="7.2.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -86,7 +86,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0 Libation Tests", "0 Libat
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternalUtilities.Tests", "_Tests\InternalUtilities.Tests\InternalUtilities.Tests.csproj", "{8447C956-B03E-4F59-9DD4-877793B849D9}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternalUtilities.Tests", "_Tests\InternalUtilities.Tests\InternalUtilities.Tests.csproj", "{8447C956-B03E-4F59-9DD4-877793B849D9}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibationSearchEngine.Tests", "_Tests\LibationSearchEngine.Tests\LibationSearchEngine.Tests.csproj", "{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibationSearchEngine.Tests", "_Tests\LibationSearchEngine.Tests\LibationSearchEngine.Tests.csproj", "{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dinah.EntityFrameworkCore.Tests", "..\Dinah.Core\_Tests\Dinah.EntityFrameworkCore.Tests\Dinah.EntityFrameworkCore.Tests.csproj", "{6F5131A0-09AE-4707-B82B-5E53CB74688E}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -214,6 +216,10 @@ Global
|
|||||||
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6F5131A0-09AE-4707-B82B-5E53CB74688E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6F5131A0-09AE-4707-B82B-5E53CB74688E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6F5131A0-09AE-4707-B82B-5E53CB74688E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6F5131A0-09AE-4707-B82B-5E53CB74688E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -249,6 +255,7 @@ Global
|
|||||||
{F3B04A3A-20C8-4582-A54A-715AF6A5D859} = {8679CAC8-9164-4007-BDD2-F004810EDA14}
|
{F3B04A3A-20C8-4582-A54A-715AF6A5D859} = {8679CAC8-9164-4007-BDD2-F004810EDA14}
|
||||||
{8447C956-B03E-4F59-9DD4-877793B849D9} = {67E66E82-5532-4440-AFB3-9FB1DF9DEF53}
|
{8447C956-B03E-4F59-9DD4-877793B849D9} = {67E66E82-5532-4440-AFB3-9FB1DF9DEF53}
|
||||||
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98} = {67E66E82-5532-4440-AFB3-9FB1DF9DEF53}
|
{C5B21768-C7C9-4FCB-AC1E-187B223D5A98} = {67E66E82-5532-4440-AFB3-9FB1DF9DEF53}
|
||||||
|
{6F5131A0-09AE-4707-B82B-5E53CB74688E} = {38E6C6D9-963A-4C5B-89F4-F2F14885ADFD}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {615E00ED-BAEF-4E8E-A92A-9B82D87942A9}
|
SolutionGuid = {615E00ED-BAEF-4E8E-A92A-9B82D87942A9}
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Octokit" Version="0.48.0" />
|
<PackageReference Include="Octokit" Version="0.50.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -7,10 +7,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||||
<PackageReference Include="coverlet.collector" Version="1.3.0">
|
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user