Base solution for your next web application
Open Closed

Component Activator: could not instantiate #2354


User avatar
0
michaelhilgers created

Hi,

I created a custom table "CustomSettings". And integrated it in the DBContext in the EF project

[DbConfigurationType(typeof(PMDbConfiguration))]
    public class PMDbContext : AbpZeroDbContext<Tenant, Role, User>
    {
        /* Define an IDbSet for each entity of the application */

        public virtual IDbSet<BinaryObject> BinaryObjects { get; set; }

        public virtual IDbSet<Friendship> Friendships { get; set; }

        public virtual IDbSet<ChatMessage> ChatMessages { get; set; }

        public virtual IDbSet<CustomSetting.CustomSetting> CustomSettings { get; set; }

        public virtual IDbSet<Land.Land> Land { get; set; }
       
       // more custom tables

        /* Default constructor is needed for EF command line tool. */
        public PMDbContext()
            : base(GetConnectionString())
        {
        }

I creadted a migration file an updated the database all works fine.

But I debug the unittest local I got an error message:

"Sequence contains no matching element"

public PMDbContext(DbConnection dbConnection)
            : base(dbConnection, true)
        {

        }

If I commented out the new "IDBSet<CustomSettings>" table in the PMDBContext class the unittests run without errors.

I can see that the DbManager threw an System.InvalidOperationException


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share the unit test causing this problem ? Can you also share your entity ?

    Thanks.

  • User Avatar
    0
    michaelhilgers created

    Hi,

    All unittests failed but I found the error...

    The error was in the entity, it was an attribute on a property :roll: :

    "[Column(TypeName = "NVARCHAR(Max)")]"

    [Column(TypeName = "NVARCHAR(Max)")]
    public string Name { get; set; }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I haven't used this attribute before. You can search for it on the web.