Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8444447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:24:01+00:00 2026-06-10T09:24:01+00:00

I have 2 classes like this: 1) public class EFInitializerLanguage : EFInitializerBase, IRepositoryInitializer<Language> {

  • 0

I have 2 classes like this:

1)

public class EFInitializerLanguage : EFInitializerBase, IRepositoryInitializer<Language>
{
    public IEntityRepository<Language> Create()
    {
        return this.Model.CreateObjectContext<LanguageData>(new SqlConnection(Utility.ConnectionStrings.ConnDefault));
    }
}

2)

public class EFInitializerPerson : EFInitializerBase, IRepositoryInitializer<Person>
    {
        public IEntityRepository<Person> Create()
        {
            return this.Model.CreateObjectContext<PersonData>(new SqlConnection(Utility.ConnectionStrings.ConnDefault));
        }
    }

And the definition in Unity.config is (probably these are wrong and I couldn’t figure out what to do)

<unity>
    <typeAliases>
<typeAlias alias="IRepositoryInitializer`1" type="Contracts.Repositories.IRepositoryInitializer`1, Contracts" />
        <typeAlias alias="EFInitializerPerson" type="Data.Initializers.EFInitializerPerson, Data" />

    <typeAlias alias="IRepositoryInitializerLanguage`1" type="Contracts.Repositories.IRepositoryInitializer`1, Contracts" />
    <typeAlias alias="EFInitializerLanguage" type="Data.Initializers.EFInitializerLanguage, Data" />
<containers>
        <container>
            <types>
<type type="IRepositoryInitializer`1" mapTo="EFInitializerPerson" />
        <type type="IRepositoryInitializerLanguage`1" mapTo="EFInitializerLanguage" />
</types>
        </container>
    </containers>
</unity>

You might think to use 1 EFInitializer instead of 2 or more, but because of the input and out type difference I couldnt not make it. At this point, I believe my current approach seems fine to me.

The error I get during RunTime is:

Resolution of the dependency failed, type =
“Contracts.DataManagers.ILanguageManager”, name = “”. Exception
message is: The current build operation (build key Build
Key[Contracts.DataManagers.ILanguageManager, null]) failed: The
current type, Contracts.DataManagers.ILanguageManager, is an
interface and cannot be constructed. Are you missing a type mapping?
(Strategy type BuildPlanStrategy, index 3)

It seems like, in the config file, the declarations must be different when it comes down to have 2 different classes that implements SAME interface.

I’d be very happy if you could point me out to the right direction.

Thanks in advance,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:24:03+00:00Added an answer on June 10, 2026 at 9:24 am

    I cannot say this is an exact solution for my problem. But I thought of a workaround; Instead of using 2 EFInitializers, I merged in to one with generic types as in below:

    public class EFInitializer<T, TP>: EFInitializerBase, IRepositoryInitializer<T> 
            where T : class
            where TP : ObjectContext, IEntityRepository<T>
        {
            public IEntityRepository<T> Create()
            {
                return this.Model.CreateObjectContext<TP>(new SqlConnection(Utility.ConnectionStrings.ConnDefault));
            }
        }
    

    and the unity configuration became into this:

    <unity>
        <typeAliases>
    <typeAlias alias="IRepositoryInitializer`1" type="Contracts.Repositories.IRepositoryInitializer`1, Contracts" />
            <typeAlias alias="EFInitializer`2" type="Data.Initializers.EFInitializer`2, Data" />
    </typeAliases>
        <containers>
            <container>
                <types>
    <type type="IRepositoryInitializer`1" mapTo="EFInitializer`2" />
    </types>
            </container>
        </containers>
    </unity>
    

    Well, with this approach at least I would not have to write EFInitializer for each entity which is pretty cool for me.

    As a result, this solution is not an exact match for my problem. Since, I still am working on the system design, perhaps I’ll run into same problem.

    Thank you for your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a set of model classes like this: public class Person
I have some classes that look like this: MODEL public abstract class BaseEntity<O extends
Supposed I have two classes like this: public class Parent { public string Id
I have classes structured like this: Public MustInherit Class A ' several properties End
I currently have service classes that look something like this public class UserService :
my code is like this: i have two classes first class: public class Box<E>
let's say I have 2 classes like this: public class Foo { [Required] public
I have three classes like this. class A { public class innerB { //Do
I have been coding classes like this: public class ReportViewModel { public string Status;
I have a classes like this: public class member { public string name {get;set;}

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.