Giter Site home page Giter Site logo

Comments (8)

asreid212 avatar asreid212 commented on August 15, 2024

Forgot to add, I am connecting to SQL Server 2012. Thanks

from permissionaccesscontrol2.

JonPSmith avatar JonPSmith commented on August 15, 2024

I haven't tested the SQL side for a while so there may well be a problem. I'm on a contract at the moment so I will look at it at the weekend.

from permissionaccesscontrol2.

JonPSmith avatar JonPSmith commented on August 15, 2024

I tried the following:

  1. I made sure I didn't have a database called PermissionAccessControl2-AspNetCoreIdentity and PermissionAccessControl2-DemoDatabase so that I was starting from stratch.
  2. I just changed the appsettings to
{
  ... other parts left out
  "DemoSetup": {
    "DatabaseSetup": "Permanent", 
    "UpdateCookieOnChange": true //this doesn't matter.
  }

And when I ran the the application it started OK. I then stopped the application and ran it again - it was fine. So I don't see your error.

Can you tell me about your PermissionAccessControl2-DemoDatabase. Is it old, or have your tried to swap over to migrations (which wouldn't work without changes). If its not that then I don't know what it is.

Let me know.

from permissionaccesscontrol2.

JonPSmith avatar JonPSmith commented on August 15, 2024

PS. I have been cleaning things up and found there were some changes to the database schema between the first version (Part 3) and the latest (Part 6). Therefore if you ran a early copy of PermissionAccessControl2 your database schema might be out of date to the current version.

from permissionaccesscontrol2.

asreid212 avatar asreid212 commented on August 15, 2024

from permissionaccesscontrol2.

JonPSmith avatar JonPSmith commented on August 15, 2024

Wow, a long answer. Here are my (short) answers.

I updated the PermissionAccessControl2 software as I created the new articles, so the version in master has everything in it. That was easier to me, but does make it harder for people to pick out the simple stuff. I'm working on a new release with code for each article/approach. Should have a article out in a few weeks which should help you and other people (I'm working on a contract so limited time at the moment).

There are two databases:

  • Standard ASP.NET Core Identity database
  • A single database that I split across to DbContexts, so people can see the two parts):
    • The extra authorisation classes (see 'ExtraAuthorizeDbContext`)
    • An example multi-tenant application (see CompanyDbContext)

This second database is created via the CombinedDbContext using context.Database.EnsureCreated in the startup code (see program.cs), which is a cheat way to do it (that's only really used in unit testing).

In a real application you would need some form of migration. I'm with you - I use SQL scripts for migrations and I have a tool called EfSchemaCompare that checks my migration matches what EF Core thinks it should be.

GenericServices - there are example applications showing how to use GenericServices with Razor Pages, MVC and Web APIs. It picks up the DbContext via dependency injection.

from permissionaccesscontrol2.

JonPSmith avatar JonPSmith commented on August 15, 2024

Hi @asreid212,

Quick update that might help you.

To help developers like you I released a major overhaul of the PermissionAccessControl2 repo over the weekend (make sure to pull the changes) and posted a new article called Part 7 – Adding the “better ASP.NET Core authorization” code into your app. In the article I show how to build a new ASP.NET Core app by copying in code from PermissionAccessControl2 into your ASP.NET Core app.

NOTE: The PermissionsOnlyApp uses EF Core Migrations and applies any outstanding migrations on startup - that isn't the best way to add migrations (and I don't use EF Core migrations myself), but it makes it easier for people to run the app to see what it does.

I hope that helps you.

from permissionaccesscontrol2.

asreid212 avatar asreid212 commented on August 15, 2024

from permissionaccesscontrol2.

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.