I'm new to EF Core and SQLite and I followed the steps at https://docs.microsoft.com/en-us/ef/core/get-started/uwp/getting-started . Everything works just fine in C#, however when translating it to VB, I get the following exception:
Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 1: 'no such table: Blogs'.'
I've tried changing the "Data Source=Blogging.db" to an absolute path, but if I do I get
Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 14: 'unable to open database file'.
'
This is what I am using right now (in the context):
Protected Overrides Async Sub OnConfiguring(optionsBuilder As DbContextOptionsBuilder)
Dim AssetsFolder As StorageFolder = _
Await Package.Current.InstalledLocation.GetFolderAsync("Assets")
optionsBuilder.UseSqlite(String.Format("Data Source={0}", _
Path.Combine(AssetsFolder.Path, "blogging.db")))
End Sub
And in the App.xaml.vb:
Sub New()
InitializeComponent()
Using db = New BloggingContext()
db.Database.Migrate()
End Using
End Sub
Any help would be much appreciated. If you require more info, please let me know and I'll gladly provide it.
Crix
The problem seems to be due to the created .cs files. When you convert the three files to .vb files, the desired tables are created and an entry is created in the EFMigrationsHistory table. I have manually converted the following files from cs to vb:
And the cs files taken from the project and the vb added. If someone now knows how to run the add-migration command for vb, that would be very helpful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.