We have 2 json files with json arrays in them, called Makes.Json and Models.Json
we then call this on local as follows for EF migration:
builder.HasData(SeedDataHelper.SeedFromJson<Make>("../project/Seeds/Makes.json"));
The seedfromjson just returns an array of the casted type.
The error when deployed to azure and running the app:
Could not find a part of the path 'C:\home\site\project\Seeds\Makes.json'.
Of course this means the file path does not exist, and kudu confirms this. How do we go about fixing this?
The app is hosted on an App Service WebApp
CodePudding user response:
If the JSON-file is part of your Visual Studio project, you can configure the property 'Copy to Output Directory': Visual Studio: Copying files to Debug or Release folder
Then you are able to reference the file with the path which matches your project structure:
builder.HasData(SeedDataHelper.SeedFromJson<Make>("Seeds/Makes.json"));
