Git Product home page Git Product logo

Comments (7)

beginor avatar beginor commented on August 30, 2024 2

Because of the issue with fluent-nhibernate, it seems joined-subclass mapping is not supported by FluentNHibernate now.

  1. Create all mappings for all classes, include NHibernate.AspNetCore.Identity 's classes , please refer to the exists hbm mappings;
  2. Just use *.hbm.xml files , don't use FluentHiberate;
  3. Use NHibernate.Mapping.Attributes, it support joined-subclass mapping with the existing hbm xml mapping , which I have tested with it before。

Personaly, I prefer to use xml mapping (*.hbm.xml), because both FluentHiberate and NHibernate.Mapping.Attributes will translate it's mapping to xml mapping at runtime. And with the help of NHibernate's xml schema (nhibernate-configuration.xsd and nhibernate-mapping.xsd) file, editing hbm file with intelli popup is easy too.

For more details, please refer to issue #10 .

from nhibernate.aspnetcore.identity.

marcelNgan avatar marcelNgan commented on August 30, 2024

@beginor have you tried using Nhibernate.Mapping.ByCode? Have the "root entity for AppRole was never registered" MappingException even when using JoinedSubclassMapping. Would love a confirmation or a way around it.

from nhibernate.aspnetcore.identity.

Elvin1492 avatar Elvin1492 commented on August 30, 2024

@marcelNgan I have already developed fluent-mapping for identity. You can find it in this repo.
@beginor , if you want I can create PR for it in here.

from nhibernate.aspnetcore.identity.

beginor avatar beginor commented on August 30, 2024

@Elvin1492 Thanks, but I do not use fluent-mapping because of #13 (comment)

from nhibernate.aspnetcore.identity.

beginor avatar beginor commented on August 30, 2024

@marcelNgan I will try using this library with NHibernate.Mapping.ByCode , But I think it should be the same as NHibernate.Mapping.Attributes, which I had test before.

from nhibernate.aspnetcore.identity.

beginor avatar beginor commented on August 30, 2024

@marcelNgan If you are using with NHibernate.Mapping.ByCode , please start with rewriting of AppRole.hbm.xml and like this :

using NHibernate;
using NHibernate.Type;
using NHibernate.Mapping.ByCode.Conformist;
using NHIdentityRole = NHibernate.AspNetCore.Identity.IdentityRole;

namespace WebTest.Entities {

    public class AppRoleMapping : JoinedSubclassMapping<AppRole> {

        public AppRoleMapping() {
            // Add NHIdentityRole as root entity first
            ExplicitDeclarationsHolder.AddAsRootEntity(typeof(NHIdentityRole));
            Extends(typeof(NHIdentityRole));
            Schema("public");
            Table("app_roles");
            Key(k => k.Column("id"));
            Property(
                p => p.Description,
                maping => {
                    maping.Column("description");
                    maping.Type(NHibernateUtil.String);
                    maping.Length(256);
                }
            );
        }

    }

}

Then compile the mapping and add them after AddIdentityMappings in Startup.cs

var cfg = new Configuration();
var file = Path.Combine(
    AppDomain.CurrentDomain.BaseDirectory,
    "hibernate.config"
);
cfg.Configure(file);
// Add identity mapping based on dialect config (dialet must contains
// PostgreSQL, MySQL or MsSql)
cfg.AddIdentityMappings();
// cfg.AddAssembly(typeof(Startup).Assembly);
var modelMapper = new NHibernate.Mapping.ByCode.ModelMapper();
modelMapper.AddMapping<AppRoleMapping>();
modelMapper.AddMapping<AppUserMapping>();
modelMapper.AddMapping<TodoItemMapping>();
var mappings = modelMapper.CompileMappingForAllExplicitlyAddedEntities();
cfg.AddMapping(mappings);

from nhibernate.aspnetcore.identity.

beginor avatar beginor commented on August 30, 2024

@Elvin1492 I think the project offluent-mapping is obsoleted, does not have any update for more then one year.

if you are interested in using of NHibernate.Mapping.ByCode, please keep track of #16 , I will refact to use NHibernate.Mapping.ByCode.

from nhibernate.aspnetcore.identity.

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.