Page 1 of 1

CRMDemo CreateDatabase error

Posted: Sat 31 Dec 2011 16:46
by dsdevoy
Hi,
I am using the crm_demo.db to generate the DataContext using VS2010 and .NET 4.0. The test code to read the existing db succeeds, but the code to create a new, empty db fails with an exception. The generated DataContext code has not been modified in any way, other than a change to the namespace to match the model dll namespace.

Code: Select all

        private CrmDemoDataContext CreateContext(string path, bool deleteExisting)
        {
            bool fileExists = File.Exists(path);
            if (!fileExists || deleteExisting)
            {
                FileStream s = File.Create(path);  // create empty file
                s.Close();
            }
            CrmDemoDataContext db = new CrmDemoDataContext(string.Format("Data Source={0}", path));
            if (!fileExists || deleteExisting)
            {
                db.CreateDatabase();
            }
            return (db);
        }

        [TestMethod]
        public void CreateDb()
        {
            string path = @"E:\Dave\projects\EF\Devart\CRMTutorial\CRMDemo\CrmDemoTest\crm_test.db";
            using (CrmDemoDataContext db = CreateContext(path, true))
            {
                Assert.IsTrue(db.Companies.Count() == 0);
            }
        }

        [TestMethod]
        public void ReadDb()
        {
            string path = @"E:\Dave\projects\EF\Devart\CRMTutorial\crm_demo.db";
            using (CrmDemoDataContext db = CreateContext(path, false))
            {
                int nCompanies = db.Companies.Count();
                Assert.IsTrue(nCompanies > 0);
            }
        }


The call to db.CreateDatabase throws a Devart.Data.Linq.LinqCommandExecutionException,
Error on executing DbCommand
Inner Exception
SQLite error \r\n \"Contact_0\":syntax error
  • at Devart.Data.Linq.LinqCommandExecutionException.CanThrowLinqCommandExecutionException(String message, Exception e)
    at Devart.Data.Linq.Provider.DataProvider.CommandExecuter.Execute(List`1 sqls)
    at Devart.Data.Linq.Provider.DataProvider.CreateDatabase(Boolean ignoreErrors, Boolean createSchema)
    at Devart.Data.SQLite.Linq.Provider.SQLiteDataProvider.CreateDatabase(Boolean ignoreErrors, Boolean createSchema)
    at Devart.Data.Linq.Provider.DataProvider.Devart.Data.Linq.Provider.IProvider.CreateDatabase(Boolean ignoreErrors, Boolean createSchema)
    at Devart.Data.Linq.DataContext.CreateDatabase(Boolean ignoreErrors, Boolean createSchema)
    at Devart.Data.Linq.DataContext.CreateDatabase()
    at CrmDemoTest.UnitTest1.CreateContext(String path, Boolean deleteExisting) in E:\Dave\projects\EF\Devart\CRMTutorial\CRMDemo\CrmDemoTest\UnitTest1.cs:line 30
    at CrmDemoTest.UnitTest1.CreateDb() in E:\Dave\projects\EF\Devart\CRMTutorial\CRMDemo\CrmDemoTest\UnitTest1.cs:line 39
[/list]

Posted: Thu 05 Jan 2012 17:31
by StanislavK
Thank you for the report, we have reproduced the issue. We will analyze it and inform you about the results.

Posted: Tue 28 Feb 2012 16:24
by StanislavK
We have fixed the CreateDatabase issue, the fix is available in the latest 3.70.311 build of dotConnect for SQLite. The new build can be downloaded from
http://www.devart.com/dotconnect/sqlite/download.html
(the trial version) or from Registered Users' Area (for users with active subscription only).

For more information about the fixes and improvements available in dotConnect for SQLite 3.70.311, please refer to
http://www.devart.com/forums/viewtopic.php?t=23472