在类库.net标准中使用字符串连接

时间:2019-05-21 18:54:40

标签: c# sql entity-framework

我以.net标准创建了一个类库。
我建立了一个保存数据库的类,但是当我尝试插入行时抛出它

  

“ System.TypeInitializationException”和内部异常
   “ FileNotFoundException”

我尝试放置字符串连接,但didint成功。

  public class StoreContext : DbContext
    {

        public StoreContext() :base()
        {
            //??????
        }
        public  DbSet<Item> Items { get; set; }
        public  DbSet<Person> Persons { get; set; }

    }


public class Manager
    {
        public Manager()
        {
            Item item = new Book("Harry Poter", 160.5f, 0, "fg59-rt59-aq74- 
bn25-157",
                350, new DateTime(2005, 02, 16), new Author("Sara Rodrigez",
                new DateTime(1974, 12, 9),null, "Brazil"));

            StoreContext ctx = new StoreContext();
            ctx.Items.Add(item);
            ctx.SaveChanges();

        }
    }

我希望最后通过UWP(UI)插入/删除/更新数据库。

0 个答案:

没有答案