Coder Social home page Coder Social logo

Comments (5)

win7user10 avatar win7user10 commented on June 28, 2024

Hi, @mehmet-erdogdu, looks like the entity doesn't contain information about table name, could you please provide your Users and Transactions models code to reproduce the issue?

from laraue.efcoretriggers.

rekosko avatar rekosko commented on June 28, 2024

I'm having the same issue. What do you mean that entity doesn't contain information about table name? All I can think about is to specify e.g.: builder.ToTable("TableName"); Is there something else that you have in mind?

from laraue.efcoretriggers.

win7user10 avatar win7user10 commented on June 28, 2024

I had this error when building a trigger for an entity that DbSet hasn't been added to DbContext. The readable exception was added for this case.

from laraue.efcoretriggers.

portno avatar portno commented on June 28, 2024

Hi,

the issue seems to appear when using inheritance. Consider this example:

public abstract class BaseModel
{
    public Guid Id { get; set; }
}
public class Product: BaseModel
{
    // ...
}

and in DbContext:

public DbSet<Product> Products { get; set; }

and somewhere in your trigger use ... , product) => product.Id === ...).
GetColumnName(MemberInfo memberInfo) gets the MemberInfo of that expression which has BaseModel as DeclaringType and not Product which is the type that is used as a table.

Adding .Entity<BaseModel>().ToTable("Whatever") can cause other issues if you did not intend ModelBase to be a table.

from laraue.efcoretriggers.

Meberem avatar Meberem commented on June 28, 2024

@portno I encountered this today with a slightly more complex setup. In my case, the base model had not been configured before the Trigger configuration runs on the builder. A simple hack that worked for me was changing the order of my IEntityTypeConfiguration<TType> from:

public class MyTypeConfiguration : IEntityTypeConfiguration<BaseModel>, IEntityTypeConfiguration<Product>
{
    public void Configure(EntityTypeBuilder<BaseModel> builder)
	{
         builder.AfterInsert(....);
    }

    public void Configure(EntityTypeBuilder<Product> builder)
	{
    }
}
public class MyTypeConfiguration : IEntityTypeConfiguration<Product>, IEntityTypeConfiguration<BaseModel>
{
    public void Configure(EntityTypeBuilder<BaseModel> builder)
	{
         builder.AfterInsert(....);
    }

    public void Configure(EntityTypeBuilder<Product> builder)
	{
    }
}

I don't know if that will work for you, or what the root cause is just yet, but it might help

from laraue.efcoretriggers.

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.