GithubHelp home page GithubHelp logo

Comments (6)

ardalis avatar ardalis commented on May 15, 2024

It looks like it can't connect to the named db server at all. Make sure you have the appropriately named instance of LocalDB on your machine. In my case, I have several:

image

You should be able to pick anything, as long as you have it installed. Can you confirm you have one called (localdb)/ProjectsV13 ?

from eshoponweb.

trevor-hackett avatar trevor-hackett commented on May 15, 2024

You mention that you have SQL Server 2014 installed, but do you have SQL Server Express installed as well? I believe localdb uses SQL Server Express, usually installed with Visual Studio. You can point the connection strings to your existing SQL Server but you'd have to create the databases on the server first.

from eshoponweb.

DannyAllegrezza avatar DannyAllegrezza commented on May 15, 2024

@ardalis @yarrgh thanks for the quick response!

explorer

I have SQL Server Express 2016 installed as well as SSMS 2014. I have been using localdb for my other projects. I've tried modifying my connection strings multiple times, testing out different servers and databases, including (localdb)\ProjectsV13 and (localdb)\MSSQLLocalDB with no luck.

Just tried the following connection strings:

  "ConnectionStrings": {
    "CatalogConnection": "Data Source=DESKTOP-HICGBT3\\\\SQLEXPRESS01;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;User=DESKTOP-HICGBT3\\Danny",
    "IdentityConnection": "Data Source=DESKTOP-HICGBT3\\\\SQLEXPRESS01;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;Initial Catalog=Microsoft.eShopOnWeb.Identity;User=DESKTOP-HICGBT3\\Danny"
  }

which generated these new errors: https://gist.github.com/DannyAllegrezza/89232ac7aa17969cb0342343b131b439

from eshoponweb.

DannyAllegrezza avatar DannyAllegrezza commented on May 15, 2024

Closing this issue.

So I'm not really sure which fixed the problem, but I took these steps:

  • Delete the existing migrations, see if I could recreate them.
    At first, this did not work. I received the following error:
An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: One or more errors occurred. (Instance failure.)
Unable to create an object of type 'AppIdentityDbContext'. Add an implementation of 'IDesignTimeDbContextFactory<AppIdentityDbContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.

Googling the error led me to this StackOverflow post which mentions how the seed data could cause an issue.

  • I commented out the lines below //Seed Data in ConfigureProduction() and ConfigureDevelopment() which looked like:
            //Seed Data
            CatalogContextSeed.SeedAsync(app, catalogContext, loggerFactory)
            .Wait();

            var defaultUser = new ApplicationUser { UserName = "[email protected]", Email = "[email protected]" };
            userManager.CreateAsync(defaultUser, "Pass@word1").Wait();

Aside: Where do these methods get called from? I tried to view the call hierarchy and did not see where they are called from...?

  • After commenting out the seed data, I was able to run the create migration commands successfully.. finally!
λ dotnet ef migrations add InitialIdentityModel --context appidentitydbcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj -o Identity/Migrations
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\Danny\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.EntityFrameworkCore.Infrastructure[100403]
      Entity Framework Core 2.0.0-rtm-26452 initialized 'AppIdentityDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
Done. To undo this action, use 'ef migrations remove'

λ dotnet ef migrations add InitialModel --context catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj -o Data/Migrations
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\Danny\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.EntityFrameworkCore.Infrastructure[100403]
      Entity Framework Core 2.0.0-rtm-26452 initialized 'CatalogContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
Done. To undo this action, use 'ef migrations remove'

Then I was able to run the dotnet ef database update commands which successfully created the databases. After this, I uncommented the seed functionality and started up the application, which is now working for me.

working

from eshoponweb.

ardalis avatar ardalis commented on May 15, 2024

Are you running on the latest version of the master branch? The seed data thing is a known EF Core 2.0 breaking change that was fixed in the latest version of the sample. The seed data is now done in Program.cs:

https://github.com/dotnet-architecture/eShopOnWeb/blob/master/src/Web/Program.cs#L18-L36

If you were still seeing it in Startup.cs I think you were on an older version.

from eshoponweb.

DannyAllegrezza avatar DannyAllegrezza commented on May 15, 2024

Oh man, I was behind by like 17 commits. Glad to know about the seed data thing. I appreciate all of the help @ardalis 👍

btw: I've really enjoyed all of your PluralSight courses. Great stuff!

from eshoponweb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.