lundi 16 novembre 2015

How do I reference an EF Configuration in another project via reflection?

I'm trying to create a console application for generating a SQL Migration script for automation purposes - the same script generated by:

Update-Database -Script

From Package Manager Console.

In the console app I've created I can generate the script if I reference the DLL directly that has my DBMigrationsConfiguration in it.

For example this works:

enter image description here

Note I have a direct reference to the DLL, a using statement and I use a new statement to instantiate the Config object.

Now if I try to do it via reflection I get back null from the line:

DbMigrationsConfiguration configuration = (DbMigrationsConfiguration)assembly.CreateInstance("TAPS.Infrastructure.Migrations, Configuration");            

The full code sample follows:

enter image description here





Aucun commentaire:

Enregistrer un commentaire