-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RemoveRange Error when removing multiple records in UWP and SQLite #3273
Comments
To diagnose this better, we need to log what is actually being sent to SQLite. It's unfortunately hacky, but here are some instructions for adding a logger in beta6. var services = new ServiceCollection()
.AddEntityFramework()
.AddSqlite()
.ServiceCollection()
.AddInstance<ILoggerFactory>(new TestSqlLoggerFactory())
.BuildServiceProvider();
var context = new EwDataContext(services); // will need to add new ctor that takes IServiceProvider
// proceed with business as usual (this is what we do in NorthwindQuerySqliteFixture). Use the TestSqlLoggerFactory from this file. When you hit the exception, break execution and examine what is in |
@waterfallbay You could just try using the DNXCORE implementation instead. |
(Doh - I read more carefully. You're on UWP.) UWP doesn't have the DNXCORE50 compile symbol defined. Change this to NETFX_CORE. |
@natemcmaster TestSqlLoggerFactory works now after changing the symbol to NETFX_CORE. Thanks. But the logger still does not work, it show errors on var services = new ServiceCollection()
.AddEntityFramework()
.AddSqlite()
.ServiceCollection()
.AddInstance<ILoggerFactory>(new TestSqlLoggerFactory())
.BuildServiceProvider(); stating that it does not contain a definition for "ServiceCollection", please help. |
@waterfallbay Ah yes. We added var collection = new ServiceCollection();
collection.AddEntityFramework().AddSqlite();
collection.AddInstance<ILoggerFactory>(new TestSqlLoggerFactory());
var services = collection.BuildServiceProvider(); |
@natemcmaster i have implemented what you have suggested and run successfully. However, would you please advise where would TestSqlLoggerFactory.Sql file saved? Since i can't locate it. |
To clarify, it does not save a file. The sql can be inspected in memory. Run your app in debug mode. When you hit your error, inspect the static field TestSqlLogger.Sql in your IDE. |
@natemcmaster I've make a breakpoint in TestSqlLoggerFactory.cs > SqlLogger > _testOutputHelper?.WriteLine(format + Environment.NewLine);
Another observation is, my test function should delete 3 rows from DB ( we have 5 rows and select all those ID > 2 to delete) but the program only generate 2 delete statements to delete id=3 and id=4 only and throw the above exception, id=5 is leaving intact. Please help. |
It appears the database isn't missing, so this is likely the same issue as aspnet/Microsoft.Data.Sqlite#116. This issue is caused by the goofy filesystem permissions on UWP. Can you try the workaround in this post? (i.e. add the following to your code at the beginning of your application, before EF is every opened). // add this to your startup class
[DllImport("sqlite3", EntryPoint = "sqlite3_win32_set_directory", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
static extern int SetDirectory(uint directoryType, string directoryPath);
//before EF runs, call...
SetDirectory(2, Windows.Storage.ApplicationData.Current.TemporaryFolder.Path); |
@natemcmaster i can solve the issue with your workaround so your guess is correct and this should be the same issue as in aspnet/Microsoft.Data.Sqlite#116 |
I have run the below code to get all shop types from SQLite with shopTypeId >2, and then removed them all in a batch:
However, the program return me an error by stating that:
I have no such error if the size of the list to be deleted is 1, or I delete that one by one instead of deleting them all at a batch.
Environment:
VS 2015 Enterprise
EntityFramework.Commands: "7.0.0-beta6"
EntityFramework.SQLite: "7.0.0-beta6"
Microsoft.CodeAnalysis.CSharp: "1.0.0"
Please help. Thanks.
The text was updated successfully, but these errors were encountered: