Skip to content
This repository was archived by the owner on Dec 2, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,6 @@ ModelManifest.xml

# FAKE - F# Make
.fake/

# Jetbrains Rider files
.idea/
7 changes: 7 additions & 0 deletions .idea/.idea.CheeseMVC/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Fix for LC101 students using Unix based systems (OSX or Linux)

### Sources

- https://medium.com/@yostane/entity-framework-core-and-sqlite-getting-started-on-macos-and-visual-studio-code-27f3830db77c
- https://docs.microsoft.com/en-us/ef/core/miscellaneous/configuring-dbcontext
- one very long night

### Note
#### this project was written in JetBrains Rider. It should be compatible with Visual Studio but if not just use the modified files below:

- src/CheeseMVC/Data/CheeseDbContext.cs
- src/CheeseMVC/CheeseMVC.csproj
- src/CheeseMVC/Startup.cs
- src/CheeseMVC/appsettings.json


\- Vamp
18 changes: 7 additions & 11 deletions src/CheeseMVC/CheeseMVC.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.4" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0-preview1-final" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions src/CheeseMVC/Data/CheeseDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace CheeseMVC.Data
public class CheeseDbContext : DbContext
{
public DbSet<Cheese> Cheeses { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
// Specify the path of the database here
optionsBuilder.UseSqlite("Data Source=./CheeseMVC.sqlite");
}

public CheeseDbContext(DbContextOptions<CheeseDbContext> options)
: base(options)
Expand Down
2 changes: 1 addition & 1 deletion src/CheeseMVC/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void ConfigureServices(IServiceCollection services)
{

services.AddDbContext<CheeseDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
options.UseSqlite("DataSource=CheeseMVC.sqlite"));

// Add framework services.
services.AddMvc();
Expand Down
3 changes: 0 additions & 3 deletions src/CheeseMVC/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=CheeseMVC-persistent;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
Expand Down