0

In my .Net MAUI project I'm trying to change update my migration. I added a property to my model and did;

  1. Add-Migration AddBlogCreatedTimestamp in the packet manager console
  2. Update-Database in the packet manager console

It tells me 'build succeeded' but also give me the error "Startup project targets platform 'Android'. The Entity Framework Core .NET Command-line Tools don't support this platform"

When I try to run the app on my android phone I get: Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 1: 'no such column: t.Description'.' Description being the property I added to the model.

When I run the app on windows it works fine.

Is there anyway around this? I read the page that comes with the error but that didn't help me.

Woetroe
  • 55
  • 5
  • You can [answer your own question](https://stackoverflow.blog/2009/01/06/accept-your-own-answers/) with your solution(Edited section) and accept it as an answer if it's helpful to others facing the same problem. – Jianwei Sun - MSFT Feb 14 '23 at 07:41

2 Answers2

1

Update: After changing the name of my Dbpath in taskcontext I got it to work. Not sure how. Maybe I messed with it a while back and I changed it to the original name back now.

    public TaskContext()
    {
        var folder = 
        Environment.SpecialFolder.LocalApplicationData;
        var path = Environment.GetFolderPath(folder);
        DbPath = System.IO.Path.Join(path, "Todo.db");
        Database.EnsureCreated();
    }

The DBPath was "ToDo.db" before

Woetroe
  • 55
  • 5
0
  • As indicated in the link you provided: you'll need to create a dummy project (using .Net Core or .Net Framework) to represent the startup project.

  • The command now would be something like this:

    Add-Migration AddBlogCreatedTimestamp -StartupProject <path-to-your-dummy-project>

Hoàng Trần
  • 549
  • 6
  • 14
  • Trying that gives me "The '<' operator is reserved for future use" and without the < and > it gives me: "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Project '(ProjectName)' is not found.PM> – Woetroe Feb 06 '23 at 13:49
  • Did you try project name only? Like: `Add-Migration AddBlogCreatedTimestamp -StartupProject DummyProject` – Hoàng Trần Feb 06 '23 at 14:27
  • Yes I did try that – Woetroe Feb 06 '23 at 18:09