c# - Get project path from POCO migration Seed() -
i'm trying executable path within seed() thread. i'm not getting values want. aim enumerate files within executable path, , work those;
internal sealed class configuration : dbmigrationsconfiguration<dbcontext> { public configuration() { automaticmigrationsenabled = true; } protected override void seed(dbcontext context) { // list of files var sqlfilelist = directory.getfiles(system.reflection.assembly.getentryassembly().location); } }
output package manager console;
object reference not set instance of object.
i'm expecting;
c:\development\my.domain
you should use system.reflection.assembly.getentryassembly().location
note return path of process exe.
you'll have use system.io.path.getdirectoryname(path)
path of directory containing process exe.
for msdn :
getcallingassembly
=> assembly of method invoked executing method. getexecutingassembly
=> assembly contains code executing. getentryassembly
=> assembly process executable.
Comments
Post a Comment