Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cloud0259/MauiSqlite

Repository files navigation

License: MIT

.Net MAUI SQLite Sample

Sample built with .Net MAUI.

This sample implements SQLite with Entity Framework Core.

Documentation

the application is based on three projects:

  • A Domain project for the models
  • An Infrastructure project for database management
  • The MAUI project

Usage/Examples

Before the first launch, be sure to perform a migration in the Infrastructure project

dotnet ef migrations add Initial_Create
dotnet ef database update

If you add a new migrations, make previous commands

Don't use Database.EnsureCreated() for SQLite otherwise the migrations will no longer work

To change the path of the .db file, you must edit the BlogContextFactory file and in the BlogContext (An appsettings.json file is recommended)

 public class BlogContextFactory : IDesignTimeDbContextFactory<BlogContext>
    {
        public BlogContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder<BlogContext>();
            var sqlitePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "blog.db");
            optionsBuilder.UseSqlite($"Data Source={sqlitePath}");

            return new BlogContext(optionsBuilder.Options);
        }
    }

.Net MAUI Links

.Net Foundation

There are many .NET related projects on GitHub.

  • .NET home repo - links to hundreds of .NET projects, from Microsoft and the community.
  • ASP.NET Core home - the best place to start learning about ASP.NET Core.

Authors

License

.NET (including the maui-samples repo) is licensed under the MIT license.

About

Sample built with .Net MAUI. This sample implements SQLite with Entity Framework Core.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages