|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Linq2Sql issues<Short Version> 1 - Linq To Sql designer has problems with multi-level namespace. View Code generates error "The name SimpleNS.SubNS is not a valid identifier. Please choose a different name." code generated ignores namespace 2 - resetting DataContext.ConnectionString , the following code generates exceptions : DeleteDatabase(); // tries to delete db from original ConnectionString if ( !DatabaseExists() ) { string path=DatabaseFilename(); // DatabaseFilename : method to extract db file path from connection string Directory.CreateDirectory( Path.GetDirectoryName( path ) ); CreateDatabase(); // db file already exists - I know it doesn't & we just dropped through !DatabaseExists() } </Short Version> <Long Version> 1 - the Linq to Sql designer seems to have problems bringing up the code window when using a 'multi-level' namespace. using a namespace of SimpleNS, everything works fine - we get : namespace SimpleNS { partial class Linq2SqlDataContext { } } setting the namespace to SimpleNS.SubNS & selecting 'View Code' causes the error "The name SimpleNS.SubNS is not a valid identifier. Please choose a different name." using a single level namespace, we get : partial class Linq2SqlDataContext { } if I fix the code manually everything works fine, until I do another 'View Code' where i get the same error message again and this code is generated : partial class Linq2SqlDataContext { } namespace SimpleNS.SubNS { partial class Linq2SqlDataContext { } } 2 - I have my LinqToSql in a library. I have an SqlExpress database setup for library development, the DataContext has the Applications Settings property set to true. I tried to create an app setting that would override the library setting but the DataContext continued to reference the library connection string. So instead I added modified the DataContext.OnCreated() method to change the Connection.ConnectionString to the proper connection string for the application. This worked fine. My next step was to have the DataContext check for the existance of the database file and if it wasn't found then create it. as : if ( !DatabaseExists() ) { string path=DatabaseFilename(); // DatabaseFilename : method to extract db file path from connection string Directory.CreateDirectory( Path.GetDirectoryName( path ) ); CreateDatabase(); } this worked fine. Then I deleted the app db. When I reran the app the CreateDatabase() generated an exception stating that the db file already existed, which I know it didn't because I completely deleted the file & parent folder and DatabaseExists() had just returned false ! I rebooted assuming this was some type of caching issue. After reboot the problem persisted.So I changed my code to be : try { DeleteDatabase(); } catch(Exception e) { } if ( !DatabaseExists() ) { string path=DatabaseFilename(); // DatabaseFilename : method to extract db file path from connection string Directory.CreateDirectory( Path.GetDirectoryName( path ) ); CreateDatabase(); } Now the DeleteDatabase() generated an exception : db file does not exist. This would be fine except that the filename in the exception message was for the db file in the library and not the application !!! So I add the following to the DataContext to get the proper db files deleted : public new void DeleteDatabase(){ File.Delete( DatabaseFilename() ); File.Delete( DatabaseFilename().Replace(".mdf","_log.LDF") ); } I changed the App db location and the create worked fine. Running this again, the delete deleted the proper files BUT the create threw the same file exists exception. </Long Version> Maybe this Linq To Sql / DataContext stuff is not quite ready for prime time ? Anyone know if the source for System.Data.Linq.DataContext is available somehwere ? I'd like to follow through the CreateDatabase/DeleteDatabase/DatabaseExists methods to see what is going on. Gerry Hello Gerry,
#1 I reproduced this behavior on my VS 2008. The reproduce steps is as blow: 1. Created a Winform application. 2. Add new item LinqToSQL. 3. Drag-drop a table from Sever Explorer to LinqToSQl designer interface. 4. Change the "Entity Namespace" property of DataContext to "SimpleTest.subtest" 5. After I click "View Code" on Table, I get the error message "The name SimpleNS.SubNS is not a valid identifier. Please choose a different name." 6. If I fix the code manually, it works fine. But if I do 'View Code' again, I get the same error message. Please feel free to correct me if I'm missing anything here. This seems like a product issue. I think I need consult product team. I will reply you as soon as possible. If you have any more concerns on it, please feel free to post here. Thanks for your understanding. #2 It sounds like what you need is the soure code for System.Data.Linq.DataContext , correct? If I misunderstood anything, please don't hesitate to correct me. If this case, I suggest you can use Reflector. It is a free and powerful tool which could be used for decompiling .net assemblies. You can download it at http://www.aisto.com/roeder/dotnet/ You can load data.linq.dll into Reflector for analyse. System.data.linq.dll is located in C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll. Hope this helps. Please feel free to update here again, if there is anything unclear. We are glad to assist you. Have a great day, Best regards, Wen Yuan Microsoft Online Community Support ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Thanks for the reply.
Please see my second post under this thread. I agree that #1 looks like a bug in the VS2008 Link2Sql Designer for #2 I have found this to be multiple issues : a) DataContext is not performing literal substitution on the connection string as I beleive it should - ie |DataDirectory| is not being replaced resulting in 'Invalid character' exceptions. b) Modifying the DataContext.Connection.ConnectionString anywhere but in the constructor does not properly propgate the change through out the DataContext ie. DeleteDatabase() c) it looks like somehow, sql server express has made a permanent association between the database filename& location with an existing database with the same name in another project. changing the database name or location fixes the DatabaseExists()/CreateDatabase()/DeleteDatabase() problems. A new question comes out of this - how do I find/delete these database name/location associations within Sql Server Express 2005 ? Gerry Show quote "WenYuan Wang [MSFT]" <v-wyw***@online.microsoft.com> wrote in message news:GZqU1EPMIHA.6908@TK2MSFTNGHUB02.phx.gbl... > Hello Gerry, > > #1 > I reproduced this behavior on my VS 2008. The reproduce steps is as blow: > 1. Created a Winform application. > 2. Add new item LinqToSQL. > 3. Drag-drop a table from Sever Explorer to LinqToSQl designer interface. > 4. Change the "Entity Namespace" property of DataContext to > "SimpleTest.subtest" > 5. After I click "View Code" on Table, I get the error message "The name > SimpleNS.SubNS is not a valid identifier. Please choose a different name." > 6. If I fix the code manually, it works fine. But if I do 'View Code' > again, I get the same error message. > Please feel free to correct me if I'm missing anything here. > > This seems like a product issue. I think I need consult product team. I > will reply you as soon as possible. If you have any more concerns on it, > please feel free to post here. Thanks for your understanding. > > #2 > It sounds like what you need is the soure code for > System.Data.Linq.DataContext , correct? If I misunderstood anything, > please > don't hesitate to correct me. > > If this case, I suggest you can use Reflector. It is a free and powerful > tool which could be used for decompiling .net assemblies. You can download > it at http://www.aisto.com/roeder/dotnet/ > You can load data.linq.dll into Reflector for analyse. > System.data.linq.dll is located in C:\Program Files\Reference > Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll. > > Hope this helps. Please feel free to update here again, if there is > anything unclear. We are glad to assist you. > > Have a great day, > Best regards, > > Wen Yuan > Microsoft Online Community Support > ================================================== > This posting is provided "AS IS" with no warranties, and confers no > rights. > Hello Gerry,
Thanks for your reply. First of all, I'd like to summary what I understood. a) I understood you received an "Invalid Character" exception when the connection for DataContext includes "|DataDirectory|". Please don't hesitate to correct me if I misunderstood anything here. If this is the case, do you have any simple code to reproduce this issue? I have tried it on my side. But, it seems works fine. I follow the steps as below: 1) Add linqtosql into my project. 2) Add a new connection (attached file) in Server Explorer. 3) Drag-drop a table into linqtosql designer interface. 4) The connection of datacontext is [Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\testDB.mdf;Integrated Security=True;User Instance=True] 5) At last, I add the following code in my application. private void button1_Click(object sender, EventArgs e) { ClassLibrary1.DataClasses1DataContext dccdc = new ClassLibrary1.DataClasses1DataContext(); bool f = dccdc.DatabaseExists(); } It works file. The value retried by DataExists method is true. I didn't get any error message. If I'm missing anything here, please correct me. b) I understood the issue is that change the DataConext.connection.connectionstring anywhere but in constructor doesn't take effect, correct? Please correct me if I misunderstood anything here. I made change on DataContext.connecton in my application, and check that property again. It really takes effect. Did I miss anything here? please correct me. ClassLibrary1.DataClasses1DataContext dccdc = new ClassLibrary1.DataClasses1DataContext(); dccdc.Connection.ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=test;Integrated Security=True"; System.Windows.Forms.MessageBox.Show(dccdc.Connection.ConnectionString); c) It seems what your main concern is that CreatDatabase() method throws "already exists" exception even though DatabaseExists return false (and the db file doesn't exists). If I misunderstood anything here, please correct me. I'm not a SQL guy, but I'm sorry to say I don't think SQL Express makes a permanent association between the database filename and location. Do you have any reproduce steps for us? It will help on research very much. Thanks. Please feel free to update here again, if you have any more concern. We are glad to assist you. Have a great day, Best regards, Wen Yuan Microsoft Online Community Support ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. a - DatabaseExists() in this case does not cause an error but always
returning false, CreateDatabase() will throw Invalid Character exception b - same as above - DatabaseExists() will not error out but Create/Delete will at the very least reference the incorrect connectionstring c - again DatabaseExists() does not throw the exception CreateDatabase() does. Please see http://dev.gerzio.ca/Linq.zip for a simple but complete solution that demonstrates 3 apparent issues : 1 - |DataDirectory| substitution is not occuring 2 - non-existant databases resulting in database already exists errors on CreateDatabase() 3 - ( a new one ) CreateDatabase modifies the Connection.ConnectionString causing some subsequent commands to fail Gerry Show quote "WenYuan Wang [MSFT]" <v-wyw***@online.microsoft.com> wrote in message news:9QimjcbMIHA.4380@TK2MSFTNGHUB02.phx.gbl... > Hello Gerry, > Thanks for your reply. > > First of all, I'd like to summary what I understood. > > a) I understood you received an "Invalid Character" exception when the > connection for DataContext includes "|DataDirectory|". Please don't > hesitate to correct me if I misunderstood anything here. > > If this is the case, do you have any simple code to reproduce this issue? > I > have tried it on my side. But, it seems works fine. I follow the steps as > below: > > 1) Add linqtosql into my project. > 2) Add a new connection (attached file) in Server Explorer. > 3) Drag-drop a table into linqtosql designer interface. > 4) The connection of datacontext is > [Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\testDB.mdf;Integrated > Security=True;User Instance=True] > 5) At last, I add the following code in my application. > > private void button1_Click(object sender, EventArgs e) > { > ClassLibrary1.DataClasses1DataContext dccdc = new > ClassLibrary1.DataClasses1DataContext(); > bool f = dccdc.DatabaseExists(); > > } > > It works file. The value retried by DataExists method is true. I didn't > get > any error message. If I'm missing anything here, please correct me. > > b) I understood the issue is that change the > DataConext.connection.connectionstring anywhere but in constructor doesn't > take effect, correct? Please correct me if I misunderstood anything here. > > I made change on DataContext.connecton in my application, and check that > property again. It really takes effect. Did I miss anything here? please > correct me. > > ClassLibrary1.DataClasses1DataContext dccdc = new > ClassLibrary1.DataClasses1DataContext(); > dccdc.Connection.ConnectionString = @"Data Source=.\sqlexpress;Initial > Catalog=test;Integrated Security=True"; > System.Windows.Forms.MessageBox.Show(dccdc.Connection.ConnectionString); > > c) It seems what your main concern is that CreatDatabase() method throws > "already exists" exception even though DatabaseExists return false (and > the > db file doesn't exists). If I misunderstood anything here, please correct > me. I'm not a SQL guy, but I'm sorry to say I don't think SQL Express > makes > a permanent association between the database filename and location. Do you > have any reproduce steps for us? It will help on research very much. > Thanks. > > Please feel free to update here again, if you have any more concern. We > are > glad to assist you. > > Have a great day, > Best regards, > > Wen Yuan > Microsoft Online Community Support > ================================================== > This posting is provided "AS IS" with no warranties, and confers no > rights. > I added a 4th issue to the sample solution :
4 - changing the ConnectionString after the base constructor - results in mixed usage of original & current connection strings. CreateDatabase() - uses current connection string DeleteDatabase() - uses original connection string DatabaseExists() - uses original connection string Show quote "gerry" <germ@nospam.nospam> wrote in message news:uZfmh9dMIHA.1204@TK2MSFTNGP03.phx.gbl... >a - DatabaseExists() in this case does not cause an error but always > returning false, CreateDatabase() will throw Invalid Character exception > b - same as above - DatabaseExists() will not error out but Create/Delete > will at the very least reference the incorrect connectionstring > c - again DatabaseExists() does not throw the exception CreateDatabase() > does. > > > Please see http://dev.gerzio.ca/Linq.zip for a simple but complete > solution that demonstrates 3 apparent > issues : > > 1 - |DataDirectory| substitution is not occuring > 2 - non-existant databases resulting in database already exists errors > on CreateDatabase() > 3 - ( a new one ) CreateDatabase modifies the > Connection.ConnectionString causing some subsequent commands to fail > > Gerry > > > > "WenYuan Wang [MSFT]" <v-wyw***@online.microsoft.com> wrote in message > news:9QimjcbMIHA.4380@TK2MSFTNGHUB02.phx.gbl... >> Hello Gerry, >> Thanks for your reply. >> >> First of all, I'd like to summary what I understood. >> >> a) I understood you received an "Invalid Character" exception when the >> connection for DataContext includes "|DataDirectory|". Please don't >> hesitate to correct me if I misunderstood anything here. >> >> If this is the case, do you have any simple code to reproduce this issue? >> I >> have tried it on my side. But, it seems works fine. I follow the steps as >> below: >> >> 1) Add linqtosql into my project. >> 2) Add a new connection (attached file) in Server Explorer. >> 3) Drag-drop a table into linqtosql designer interface. >> 4) The connection of datacontext is >> [Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\testDB.mdf;Integrated >> Security=True;User Instance=True] >> 5) At last, I add the following code in my application. >> >> private void button1_Click(object sender, EventArgs e) >> { >> ClassLibrary1.DataClasses1DataContext dccdc = new >> ClassLibrary1.DataClasses1DataContext(); >> bool f = dccdc.DatabaseExists(); >> >> } >> >> It works file. The value retried by DataExists method is true. I didn't >> get >> any error message. If I'm missing anything here, please correct me. >> >> b) I understood the issue is that change the >> DataConext.connection.connectionstring anywhere but in constructor >> doesn't >> take effect, correct? Please correct me if I misunderstood anything here. >> >> I made change on DataContext.connecton in my application, and check that >> property again. It really takes effect. Did I miss anything here? please >> correct me. >> >> ClassLibrary1.DataClasses1DataContext dccdc = new >> ClassLibrary1.DataClasses1DataContext(); >> dccdc.Connection.ConnectionString = @"Data Source=.\sqlexpress;Initial >> Catalog=test;Integrated Security=True"; >> System.Windows.Forms.MessageBox.Show(dccdc.Connection.ConnectionString); >> >> c) It seems what your main concern is that CreatDatabase() method throws >> "already exists" exception even though DatabaseExists return false (and >> the >> db file doesn't exists). If I misunderstood anything here, please correct >> me. I'm not a SQL guy, but I'm sorry to say I don't think SQL Express >> makes >> a permanent association between the database filename and location. Do >> you >> have any reproduce steps for us? It will help on research very much. >> Thanks. >> >> Please feel free to update here again, if you have any more concern. We >> are >> glad to assist you. >> >> Have a great day, >> Best regards, >> >> Wen Yuan >> Microsoft Online Community Support >> ================================================== >> This posting is provided "AS IS" with no warranties, and confers no >> rights. >> > > > > work arround for #1 -
use following as base class for DataContext namespace Gms.Data.Linq { public class DataContext : System.Data.Linq.DataContext { public DataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : base( Gms.Util.Config.FixDataDirectory( connection ) , mappingSource ) { } public DataContext( System.Data.IDbConnection connection , System.Data.Linq.Mapping.MappingSource mappingSource ) : base(connection, mappingSource) { } } } Show quote "gerry" <germ@nospam.nospam> wrote in message news:eRKaoknMIHA.4712@TK2MSFTNGP04.phx.gbl... >I added a 4th issue to the sample solution : > 4 - changing the ConnectionString after the base constructor - results > in mixed usage of original & current connection strings. > CreateDatabase() - uses current connection string > DeleteDatabase() - uses original connection string > DatabaseExists() - uses original connection string > > > "gerry" <germ@nospam.nospam> wrote in message > news:uZfmh9dMIHA.1204@TK2MSFTNGP03.phx.gbl... >>a - DatabaseExists() in this case does not cause an error but always >> returning false, CreateDatabase() will throw Invalid Character exception >> b - same as above - DatabaseExists() will not error out but Create/Delete >> will at the very least reference the incorrect connectionstring >> c - again DatabaseExists() does not throw the exception CreateDatabase() >> does. >> >> >> Please see http://dev.gerzio.ca/Linq.zip for a simple but complete >> solution that demonstrates 3 apparent >> issues : >> >> 1 - |DataDirectory| substitution is not occuring >> 2 - non-existant databases resulting in database already exists errors >> on CreateDatabase() >> 3 - ( a new one ) CreateDatabase modifies the >> Connection.ConnectionString causing some subsequent commands to fail >> >> Gerry >> >> >> >> "WenYuan Wang [MSFT]" <v-wyw***@online.microsoft.com> wrote in message >> news:9QimjcbMIHA.4380@TK2MSFTNGHUB02.phx.gbl... >>> Hello Gerry, >>> Thanks for your reply. >>> >>> First of all, I'd like to summary what I understood. >>> >>> a) I understood you received an "Invalid Character" exception when the >>> connection for DataContext includes "|DataDirectory|". Please don't >>> hesitate to correct me if I misunderstood anything here. >>> >>> If this is the case, do you have any simple code to reproduce this >>> issue? >>> I >>> have tried it on my side. But, it seems works fine. I follow the steps >>> as >>> below: >>> >>> 1) Add linqtosql into my project. >>> 2) Add a new connection (attached file) in Server Explorer. >>> 3) Drag-drop a table into linqtosql designer interface. >>> 4) The connection of datacontext is >>> [Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\testDB.mdf;Integrated >>> Security=True;User Instance=True] >>> 5) At last, I add the following code in my application. >>> >>> private void button1_Click(object sender, EventArgs e) >>> { >>> ClassLibrary1.DataClasses1DataContext dccdc = new >>> ClassLibrary1.DataClasses1DataContext(); >>> bool f = dccdc.DatabaseExists(); >>> >>> } >>> >>> It works file. The value retried by DataExists method is true. I didn't >>> get >>> any error message. If I'm missing anything here, please correct me. >>> >>> b) I understood the issue is that change the >>> DataConext.connection.connectionstring anywhere but in constructor >>> doesn't >>> take effect, correct? Please correct me if I misunderstood anything >>> here. >>> >>> I made change on DataContext.connecton in my application, and check that >>> property again. It really takes effect. Did I miss anything here? please >>> correct me. >>> >>> ClassLibrary1.DataClasses1DataContext dccdc = new >>> ClassLibrary1.DataClasses1DataContext(); >>> dccdc.Connection.ConnectionString = @"Data Source=.\sqlexpress;Initial >>> Catalog=test;Integrated Security=True"; >>> System.Windows.Forms.MessageBox.Show(dccdc.Connection.ConnectionString); >>> >>> c) It seems what your main concern is that CreatDatabase() method throws >>> "already exists" exception even though DatabaseExists return false (and >>> the >>> db file doesn't exists). If I misunderstood anything here, please >>> correct >>> me. I'm not a SQL guy, but I'm sorry to say I don't think SQL Express >>> makes >>> a permanent association between the database filename and location. Do >>> you >>> have any reproduce steps for us? It will help on research very much. >>> Thanks. >>> >>> Please feel free to update here again, if you have any more concern. We >>> are >>> glad to assist you. >>> >>> Have a great day, >>> Best regards, >>> >>> Wen Yuan >>> Microsoft Online Community Support >>> ================================================== >>> This posting is provided "AS IS" with no warranties, and confers no >>> rights. >>> >> >> >> >> > > update :
1 - Linq To Sql designer has problems with multi-level namespace. View Code generates error "The name SimpleNS.SubNS is not a valid identifier. Please choose a different name." code generated ignores namespace 2 - DataContext does not seem to be doing |DataDirectory| subsitution on connection string. Added new constructor to do proper substitution ( fragile, will break if property setting name changes & doesn't fix other contructors ) public Linq2SqlDataContext( bool FixDataDirectory ) : base( (global::Test.Linq.Properties.Settings.Default.Linq2SqlConnectionString).Replace( "|DataDirectory|" , AppDomain.CurrentDomain.GetData( "DataDirectory" ) as string ) , mappingSource ) { OnCreated(); } 3 - CreateDatabase() generating aleady exists exceptions even though DatabaseExists() returns falsed ( and db file definitely does not exist ) Supposedly this problem occurs when a user instance specifies an initial catalog in the connection string. I do not specify an initial catalog in my connection string. There is disconnect here between DataContext and SqlServer regarding when/where a database does/doesn't exist. For whatever reason sql server express is associating the database file in the connection string with a cached database instance - how do we see/delete such associations ? Gerry Show quote "gerry" <germ@nospam.nospam> wrote in message news:eY4jDsEMIHA.2064@TK2MSFTNGP06.phx.gbl... >I am looking at Linq2Sql in VS2008 and have run into a couple of things : > > <Short Version> > 1 - Linq To Sql designer has problems with multi-level namespace. View > Code generates error "The name SimpleNS.SubNS is not a valid identifier. > Please choose a different name." code generated ignores namespace > > 2 - resetting DataContext.ConnectionString , the following code > generates exceptions : > > DeleteDatabase(); // tries to delete db from original > ConnectionString > > if ( !DatabaseExists() ) > { > string path=DatabaseFilename(); // DatabaseFilename : method > to extract db file path from connection string > Directory.CreateDirectory( Path.GetDirectoryName( path ) ); > CreateDatabase(); // db file already exists - I know it > doesn't & we just dropped through !DatabaseExists() > } > > </Short Version> > > <Long Version> > > 1 - the Linq to Sql designer seems to have problems bringing up the > code window when using a 'multi-level' namespace. > > using a namespace of SimpleNS, everything works fine - we get : > namespace SimpleNS > { > partial class Linq2SqlDataContext > { > } > } > > setting the namespace to SimpleNS.SubNS & selecting 'View Code' causes > the error "The name SimpleNS.SubNS is not a valid identifier. Please > choose a different name." > using a single level namespace, we get : > partial class Linq2SqlDataContext > { > } > > if I fix the code manually everything works fine, until I do another > 'View Code' where i get the same error message again and this code is > generated : > partial class Linq2SqlDataContext > { > } > namespace SimpleNS.SubNS > { > partial class Linq2SqlDataContext > { > } > } > > > 2 - I have my LinqToSql in a library. > > I have an SqlExpress database setup for library development, the > DataContext has the Applications Settings property set to true. > I tried to create an app setting that would override the library > setting but the DataContext continued to reference the library connection > string. > So instead I added modified the DataContext.OnCreated() method to > change the Connection.ConnectionString to the proper connection string for > the application. > This worked fine. > My next step was to have the DataContext check for the existance of the > database file and if it wasn't found then create it. as : > > if ( !DatabaseExists() ) > { > string path=DatabaseFilename(); // DatabaseFilename : > method to extract db file path from connection string > Directory.CreateDirectory( Path.GetDirectoryName( path ) ); > CreateDatabase(); > } > > this worked fine. > Then I deleted the app db. > When I reran the app the CreateDatabase() generated an exception > stating that the db file already existed, which I know it didn't because I > completely deleted the file & parent folder and DatabaseExists() had just > returned false ! > > I rebooted assuming this was some type of caching issue. > After reboot the problem persisted.So I changed my code to be : > > try > { > DeleteDatabase(); > } catch(Exception e) { } > if ( !DatabaseExists() ) > { > string path=DatabaseFilename(); // DatabaseFilename : > method to extract db file path from connection string > Directory.CreateDirectory( Path.GetDirectoryName( path ) ); > CreateDatabase(); > } > > Now the DeleteDatabase() generated an exception : db file does not exist. > This would be fine except that the filename in the exception message was > for the db file in the library and not the application !!! > > So I add the following to the DataContext to get the proper db files > deleted : > public new void DeleteDatabase() > { > File.Delete( DatabaseFilename() ); > File.Delete( DatabaseFilename().Replace(".mdf","_log.LDF") ); > } > > I changed the App db location and the create worked fine. > Running this again, the delete deleted the proper files BUT the create > threw the same file exists exception. > > </Long Version> > > > Maybe this Linq To Sql / DataContext stuff is not quite ready for prime > time ? > > Anyone know if the source for System.Data.Linq.DataContext is available > somehwere ? > I'd like to follow through the > CreateDatabase/DeleteDatabase/DatabaseExists methods to see what is going > on. > > Gerry > > > > |
|||||||||||||||||||||||