Repository
snowflake-efcore-provider
Entity Framework Core Provider for Snowflake This repository is in maintenance mode only by Snowflake in Snowflake-Labs. Key Points About Snowflake-Labs Repositories Critical secur · License unknown · Maintenance unknown
- License
- Unknown
README
Entity Framework Core Provider for Snowflake
This repository is in maintenance mode only by Snowflake in Snowflake-Labs.
Key Points About Snowflake-Labs Repositories
- Critical security issues will be patched if they are reported or detected.
- Official Snowflake Support will not be provided.
- The repository will not be actively monitored.
This is the open-source EF Core provider for Snowflake. It enables seamless interaction with Snowflake using Microsoft's widely-used .NET Object-Relational Mapper (ORM).
With this provider, you can write queries using familiar LINQ syntax and take advantage of the powerful features of Entity Framework Core in your Snowflake projects.
Getting Started
Installation
To install the Snowflake EF Core provider, use the following command in your .NET project:
dotnet add package Snowflake.EntityFrameworkCore
Usage
The provider integrates smoothly with Entity Framework Core, making it feel like any other EF Core provider. Here's a quick example to get started:
using Microsoft.EntityFrameworkCore;
using Snowflake.EntityFrameworkCore;
public class MyEntity
{
public int Id { get; set; }
public string Name { get; set; }
}
public class SampleDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSnowflake(
"account=<your_account>;host=<your_host>;password=<your_password>;role=<your_role>;schema=<your_schema>;user=<your_user>;warehouse=<your_warehouse>;");
}
public DbSet<MyEntity> MyEntities { get; set; }
}
class Program
{
static void Main()
{
using var context = new SampleDbContext();
context.MyEntities.Add(new MyEntity { Id = 1, Name = "Sample Entity" });
context.SaveChanges();
}
}
Development
Running Tests
The project includes two test solutions:
- Unit Tests: Located in the
EFCore.Testsproject. - Functional Tests: Located in the
Snowflake.EntityFrameworkCore.FunctionalTestsproject.
Prerequisites
To run the tests, you need to create a parameters.json file for each test project.
Should be created in the following locations:
.../EFCore.Tests/parameters.json.../tests/Snowflake.EntityFrameworkCore.FunctionalTests/parameters.json
The file should have the following structure:
{
"testconnection": {
"SNOWFLAKE_TEST_HOST": "your_host",
"SNOWFLAKE_TEST_USER": "your_user",
"SNOWFLAKE_TEST_PASSWORD": "your_password",
"SNOWFLAKE_TEST_ACCOUNT": "your_account",
"SNOWFLAKE_TEST_WAREHOUSE": "your_warehouse",
"SNOWFLAKE_TEST_DATABASE": "your_database",
"SNOWFLAKE_TEST_SCHEMA": "your_schema",
"SNOWFLAKE_TEST_ROLE": "your_role"
}
}
Steps to Run Tests
- Create a
parameters.jsonfile in the root directory of each test project using the structure provided above. - Ensure all dependencies are installed and your Snowflake test account is configured correctly.
- Run the tests using your preferred test runner (e.g., Rider Test Explorer or the
dotnet testCLI).
dotnet test EFCore.Tests
dotnet test Snowflake.EntityFrameworkCore.FunctionalTests
Contributing
We welcome contributions from the community! To contribute:
- Fork the repository and clone it locally.
- Create a new branch for your feature or bug fix.
- Run test locally.
- Commit your changes and push them to your forked repository.
- Submit a pull request detailing your changes.
References
Entity Framework Core
Scaffolding (Reverse Engineering)
Migrations Overview