zoukankan      html  css  js  c++  java
  • entity framework core + SQLite Error 1: 'no such table: Blogs'.

    在学习Entity Framework Core使用SQLite时,出现上述错误,原因是找不到db文件.

    在UseSqlite("")中添加具体的db文件路径:改成如下即可:

    protected override void OnConfiguring(DbContextOptionsBuilder options)
                => options.UseSqlite(@"Data Source=E:alexandercodesqliteEFGetStartedlogging.db");
        public class BloggingContext : DbContext
        {
            public DbSet<Blog> Blogs { get; set; }
            public DbSet<Post> Posts { get; set; }
    
            protected override void OnConfiguring(DbContextOptionsBuilder options)
                => options.UseSqlite(@"Data Source=blogging.db");
        }
    
        public class Blog
        {
            public int BlogId { get; set; }
            public string Url { get; set; }
    
            public List<Post> Posts { get; } = new List<Post>();
        }
    
        public class Post
        {
            public int PostId { get; set; }
            public string Title { get; set; }
            public string Content { get; set; }
    
            public int BlogId { get; set; }
            public Blog Blog { get; set; }
        }
  • 相关阅读:
    leetcode 34 rust
    leetcode 2 rust
    leetcode 1 rust
    leetcode 20 rust
    leetcode 287 rust
    leetcode 18 rust
    lottery抽奖
    webpack
    webpack(7)-生产环境
    webpack(6)-模块热替代&tree shaking
  • 原文地址:https://www.cnblogs.com/AlexanderZhao/p/12878865.html
Copyright © 2011-2022 走看看