async Task InitializeAsync() throwing error about the SQLite.Create flags when trying to set up SQLite with my Xamarin project

lhtyex123 21 Reputation points
2021-02-08T15:01:22.853+00:00

I have been following this tutorial:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/data/databases
to set up a local db for my application in xamarin. However, I keep experiencing the errors:
'Argument 1: cannot conver from SQLite.CreateFlags to System type'
'Argument 2: cannot convert from System.Type to SQLite.CreateFlags'
Around the following line of code:

async Task InitializeAsync()  
        {  
            if(!initialized)  
            {  
                if(!Database.TableMappings.Any(m => m.MappedType.Name == typeof(Word).Name))  
                {  
                    await Database.CreateTableAsync(CreateFlags.None, typeof(Word)).ConfigureAwait(false);  
                }  
                initialized = true;  
            }  
        }  

I am really not sure what I am doing wrong here as I am following the details in the tutorial.

Rest of the code from the same class:
public class WordSetupDatabase
{
static readonly Lazy<SQLiteAsyncConnection> lazyInitializer = new Lazy<SQLiteAsyncConnection>(() =>
{
return new SQLiteAsyncConnection(Constants.DatabasePath, Constants.Flags);
});

    static SQLiteAsyncConnection Database => lazyInitializer.Value;  
    static bool initialized = false;  

    public WordSetupDatabase()  
    {  
        InitializeAsync().SafeFireAndForget(false);  
    }  

    async Task InitializeAsync()  
    {  
        if(!initialized)  
        {  
            if(!Database.TableMappings.Any(m => m.MappedType.Name == typeof(Word).Name))  
            {  
                await Database.CreateTableAsync(CreateFlags.None, typeof(Word)).ConfigureAwait(false);  
            }  
            initialized = true;  
        }  
    }  

    public Task<List<Word>> GetItemAsync()  
    {  
        return Database.Table<Word>().ToListAsync();  
    }  

      

    public Task<int> SaveItemAsync(Word item)  
    {  
        if(item.ID != 0)  
        {  
            return Database.UpdateAsync(item);  
        }  
        else  
        {  
            return Database.InsertAsync(item);  
        }  
    }  


}  

}

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,675 questions
0 comments No comments
{count} votes