-
Notifications
You must be signed in to change notification settings - Fork 160
Closed
Description
The db init on Mac OSX with Mono seems to be a bit different:
- No SQL server locally, instead SQLite. Requires the addition of
"EntityFramework.SQLite": "7.0.0-rc1-final",
"EntityFramework.Sqlite.Design": "7.0.0-rc1-final",
to project.json.
- appsettings.json must look like this, if SQLite is used (just the Data property is of interest):
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
},
"Data": {
"PhotoGalleryConnection": {
"ConnectionString": "Data Source=./webapp.db"
}
}
}
and a ./webapp.db must exist in the root (not sure, at least I copied it to there from a project scaffolded with yo aspnet). After that "dnx ef database update" will work
- Additionally replace SQL Server setup in ConfigureServices with an SQLite setup
services.AddEntityFramework()
.AddSqlite()
.AddDbContext<PhotoGalleryContext>(options =>
options.UseSqlite(Configuration["Data:PhotoGalleryConnection:ConnectionString"]));
- Then there is an issue in DbInitializer.cs
string[] _images = Directory.GetFiles(Path.Combine(imagesPath, "wwwroot\\images"));
is not portable and leads to failures like this:
Application startup exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.DirectoryNotFoundException: Directory '/Users/decades/Angular2/aspnet5-angular2-typescript/src/PhotoGallery/wwwroot\images' not found.
Could hotfix it by
string[] _images = Directory.GetFiles("./wwwroot/images"/*Path.Combine(imagesPath, "wwwroot/images")*/);
Then the app did start at least and seemed to work.
Metadata
Metadata
Assignees
Labels
No labels