This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Like the name suggests, I'd like to run a migration that, after adding schema, has code to populate some reference data. The data code is using my model repositories that derive from LightSpeedRepository; they all pass "LightSpeed" in the base for the configuration name. Since the migrations project is a Class Library, I use the app.config to copy all relevant info, like the LightSpeed configuration section, LightSpeed config, and connection string. These are the same settings from web.config. When I run the migration, the schema is added correctly but the reference data fails with "The ConnectionString property has not been initialized." Certainly, I know why this would happen, but what I'm thinking is that if I can't read the configuration from App.config, I won't be able to do this at all. I was under the impression a migration project was just code, but I'm running into a possible limitation of RepositoryBase<T>. I've double-checked that the app.config / .dll.config file makes it into the build folder. I'm using LightSpeed 3.11. Here is what I have in my .config for the migrations project.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="lightSpeedContexts" type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" /> </configSections> <lightSpeedContexts> <clear /> <add name="LightSpeed" identityMethod="IdentityColumn" connectionStringName="ApplicationServices" dataProvider="MySql5" pluralizeTableNames="false" quoteIdentifiers="true" searchEngineClass="Mindscape.LightSpeed.Search.LuceneSearchEngine" searchEngineFileLocation="D:\Indexes" /> </lightSpeedContexts>
<connectionStrings> <clear /> <add name="ApplicationServices" connectionString="server=localhost;User Id=root;Persist Security Info=True;database=DB;password=PW"/> </connectionStrings> </configuration>
|
|
|
You're correct, a migration project is indeed just code, and you should be able to use a LightSpeedContext in a migration project just as in any other project. I'm a bit concerned by your mention of a .dll.config file though. .NET doesn't have the concept of a DLL configuration file. Unless you write specific code to look for a different file, DLLs pick up their configuration from the app.exe.config or web.config file. So you need to make sure that the LightSpeedContext configuration is included in the config file for whatever process is hosting your class library -- whether that be e.g. a console application (app.exe.config) or an admin Web site (web.config). Merely having a MyMigrations.dll.config file in the build directory will not be sufficient. Could that be the problem? |
|