Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Create CustomModelBuilder in a module class library #4788


User avatar
0
hitaspdotnet created

EF core 2 not supporting many-to-many relations without fluent or join table right now. I read a article in APB documents that related to use Data layer for mapping and data filters. So if I had a module class library please give me the tips whats steps to create CustomModelBuilder for fluent API in MyModule? I'm student special thanks for any help with inline simple code. Regards


6 Answer(s)
  • User Avatar
    0
    alper created
    Support Team
  • User Avatar
    0
    hitaspdotnet created

    [quote="alper"][list] Thank you for helpful links Is there any suggestion about fluent models builder? I think the Fluent API provider and interface's can be a good feature for ABP Framework. I don't know! Maybe I'm wrong

  • User Avatar
    0
    alper created
    Support Team

    hi

    maybe you should check this tutorial: <a class="postlink" href="https://www.tutorialspoint.com/entity_framework/entity_framework_fluent_api.htm">https://www.tutorialspoint.com/entity_f ... nt_api.htm</a>

    and official Microsoft doc: <a class="postlink" href="https://msdn.microsoft.com/en-us/library/jj591617(v=vs.113">https://msdn.microsoft.com/en-us/librar ... 7(v=vs.113</a>).aspx

  • User Avatar
    0
    hitaspdotnet created

    <cite>alper: </cite> hi

    maybe you should check this tutorial: <a class="postlink" href="https://www.tutorialspoint.com/entity_framework/entity_framework_fluent_api.htm">https://www.tutorialspoint.com/entity_f ... nt_api.htm</a>

    and official Microsoft doc: <a class="postlink" href="https://msdn.microsoft.com/en-us/library/jj591617(v=vs.113">https://msdn.microsoft.com/en-us/librar ... 7(v=vs.113</a>).aspx

    MSDN link is broken and first link tutorial is not covered by EF Core 2 because EF core 2 not generate join table. [https://github.com/aspnet/EntityFrameworkCore/issues/1368]) We need create that manually. Is can be hard for a project like eShop. Using fluent api in DbContext class's makes a ugly code if we have +10 tables. So what the best way?

  • User Avatar
    0
    hitaspdotnet created

    [https://www.learnentityframeworkcore.com/configuration/fluent-api])

    In version 2.0 onwards, this is accomplished by creating classes that implement IEntityTypeConfiguration<TEntity> and adding the fluent configuration code to a Configure method

  • User Avatar
    0
    aaron created
    Support Team

    Fluent API is the proper way.

    Using fluent api in DbContext class's makes a ugly code if we have +10 tables.

    If that's what you're concerned about, you can extract the code into a static helper similar to CustomDtoMapper.