# Veritabanı Seçme ve Bağlantı Oluşturma

Kullanmak istediğiniz veri tabanının provider ını indirmek için <https://docs.microsoft.com/tr-tr/ef/core/providers/?tabs=dotnet-core-cli> adresini ziyaret edebilirsiniz. Visual Studio kullanıyorsanız nuget paketi olarak Vs Code kullanıyorsanız cli ile ilgili provider ı yükleyebilirsiniz.&#x20;

Provider ı indirdikten sonra Context sınıfımızın içine o provider ı kullanacağımızı belirtmemiz ve connection string i yazmamız gerekmektedir.&#x20;

#### MSSQL Server Provider Kurulumu

```
public class ShopContext:DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(@"Data Source=serveradı; Initial Catalog=dbadı; Integrated Security=SSPI");
        }
}
```

#### MySql Provider Kurulumu

```
public class ShopContext:DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseMySql(@"Server=localhost;port=3306;database=dbadı;user=xxx;password=xxx");
        }
}
```

#### SqLite Provider Kurulumu

```
public class ShopContext:DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlite("Data Source=dbadı);
        }
}
```

{% hint style="info" %}
**`dotnet ef migrations add MigrationAdı`** ile yeni bir migrations oluşturup,

**`dotnet ef database update`** diyerek veri tabanımızı oluşturabiliriz.&#x20;

Eğer veri tabanı ilgili veri tabanı serverında yoksa yeni oluşturulur, varsa da değişiklikler üzerine tanımlanır.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cnahmet.gitbook.io/asp-net-notlarim/orm-entity-framework-core/veritabani-secme-ve-baglanti-olusturma.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
