locked
MEF and loading EntityTypeConfiguration in runtime

    Question

  • Hi.

    I am developing this (http://arg-co.com/SabteNam%20-%20Copy.zip) windows application, and for my DAL I use Entity Framework. But every single extension  has its own EntityTypeConfiguration, so I decided to use [Import] and [Export] to add them in OnModelCreating method of my DbContext.The  problem here is that, in 'SabteNamDbContext' class which is located on 'SabteNamDataAccess' library, the '_Configs' is not initialized so I cant iterate it and add its items to 'modelBuilder.Configurations'.

    How can this be fixed ?


    Edited : In the source code of 'SampleConfiguration' class, I commented out '[Export(typeof(IDbConfiguration))]' but even Uncommenting this part of code, do not cause application to work properly.

    Intresting point is that, if I use the following code in 'Main' windows form, the '_Configs' would be initialized  :

    [ImportMany(typeof(IDbConfiguration))]
    public IEnumerable<EntityTypeConfiguration<object>> _Configs { get; set; }

    Friday, September 30, 2011 10:51 AM