locked
Incorporating pre-existing database into new ASP.NET Core Razor app RRS feed

  • Question

  • User-971704855 posted

    I have seen an example showing the entering of "seed data" when building an ASP.NET Core Razor app...but how can I incorporate an entire pre-existing database into a new ASP.Net Core Razor app.  The database(an accdb) would be coming from a WPF/C# app with data spanning several years.

    Thanks!

    Tuesday, July 28, 2020 12:14 PM

All replies

  • User475983607 posted

    irsharp23

    have seen an example showing the entering of "seed data" when building an ASP.NET Core Razor app...but how can I incorporate an entire pre-existing database into a new ASP.Net Core Razor app.  The database(an accdb) would be coming from a WPF/C# app with data spanning several years.

    Pretty simple.  Add a connection string and a data provider.  Is accdb an MS Access DB?

    Tuesday, July 28, 2020 12:21 PM
  • User-971704855 posted

    Yes.  Thanks!

    Where to put the connection string in the code is something I'll need to work on...but thanks for the info.

    Tuesday, July 28, 2020 12:45 PM
  • User475983607 posted

    I'm not sure if there is an MS Access data provider that will work in Core 3.x.  You might have to drop to 2.0.

    Edit: connection string go in the appsettings.json file.

    Tuesday, July 28, 2020 12:52 PM
  • User-2121988648 posted

    You can scaffold Db Context:

    Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
    

     Reference:

    https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell#scaffold-dbcontext

    Please let me know if this doesn't help :)

    Tuesday, July 28, 2020 1:04 PM