dotnet / dotnet/EntityFramework.Docs

Document when the SQLite database needs to be configured for copying to the output directory

Open
#2,261 4 comments 0 reactions 0 assignees View on GitHub
area-migrations area-sqlite
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

I'm trying to implement the code based on console application sample but in WPF and I get the following error:

![image](https://user-images.githubusercontent.com/16785357/78866200-3a6d6e80-7a3f-11ea-8168-6e6e848cc152.png)

I've added the migration and updated the database. This is how my **DbContext** looks like:

```c#
public class SettingsDbContext : DbContext
{
public DbSet UserSettings { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=settings.db");

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity(c =>
{
c.HasNoKey();
c.Property(p => p.Username);
c.Property(p => p.Password);
});

modelBuilder.Entity(c =>
{
c.HasNoKey();
c.Property(p => p.Username);
c.Property(p => p.Password);
});
}
}
```

Here is how my **Model** looks like:

```c#
public class UserSettings
{
public int Id { get; set; }

public bool RememberCredentials { get; set; }

[NotMapped]
public Client1Credentials Client1Credentials { get; set; }

[NotMapped]
public Client2Credentials Client2Credentials { get; set; }
}
```

Below you can see that the migration and database were created:

![image](https://user-images.githubusercontent.com/16785357/78866458-b5368980-7a3f-11ea-9ad9-d9a7ae7f9201.png)

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 7ac57b24-45aa-e679-6ff9-5a25c369c1ff
* Version Independent ID: cc576199-b14c-a135-2291-cc48bf301b4e
* Content: [Getting Started - EF Core](https://docs.microsoft.com/en-us/ef/core/get-started/?tabs=netcore-cli)
* Content Source: [entity-framework/core/get-started/index.md](https://github.com/dotnet/EntityFramework.Docs/blob/master/entity-framework/core/get-started/index.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @Rick-Anderson
* Microsoft Alias: **avickers**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.