Search code examples
asp.net-coreazure-sql-databaseclass-library

Azure Win32Exception: The system cannot find the file specified


I have a web app (ASP.NET 5 EF 7) which is divided into several projects, among which there's one for the Identity model and one for other App Data models (both as class libraries). So in the azure web portal I have 2 servers (each with 1 db) created, one for app data and one for identity data.

When I try to register a new user I get the following error:

detailed error message

The data connections are configured OK in the portal.

In the main project I have an appsetting.json file with

  "Data": {
    "DefaultIdentityConnection": {
      "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=identityDb;Trusted_Connection=True;MultipleActiveResultSets=true"
    },
    "DefaultAppDataConnection": {
      "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=appDataDb;Trusted_Connection=True;MultipleActiveResultSets=true"
    }
}

and in each class library project (1 for identity and 1 for appdata) I have another appsettings.json file with the same connection-strings.

and the StartUp ConfigureServices looks like this: and the StartUp ConfigureServices looks like this:

services.AddEntityFramework()
    .AddSqlServer()
    .AddDbContext < IdentityContext > (options =>
        options.UseSqlServer(Configuration["Data:DefaultIdentityConnection:ConnectionString"]))
    .AddDbContext < AppDataContext > (options =>
        options.UseSqlServer(Configuration["Data:DefaultAppDataConnection:ConnectionString"]));

services.AddIdentity < ApplicationUser, IdentityRole > (
        config => {
            ....
        })
    .AddEntityFrameworkStores < IdentityContext > ()
    .AddDefaultTokenProviders();

All is well on the local machine.

What am I missing here?


Solution

  • This obviously turned out to be my fault because I had the same connection strings defined in 2 additional appsettings.json files (1 for the identity project and 1 for the app data project) and each was referenced as a configuration file in it's parent project (instead of injecting the Configuration object from Startup, I created 1 per each project - which was a bad idea), and I guess this confused things.