Created
June 15, 2019 04:51
-
-
Save ArrowCase/cd9c3ad91b1eaf0e9038a5886e5225e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.DataAnnotations; | |
using System.ComponentModel.DataAnnotations.Schema; | |
using Microsoft.EntityFrameworkCore; | |
namespace EnumRepro | |
{ | |
public class ReproDbContext : DbContext | |
{ | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ | |
if (!optionsBuilder.IsConfigured) | |
{ | |
optionsBuilder.UseSqlite(@"Data Source=repro.db"); | |
} | |
} | |
public DbSet<Model> Models { get; set; } | |
} | |
public enum State : byte | |
{ | |
One, | |
Two, | |
Three | |
} | |
public class Model | |
{ | |
[Key] | |
public int Id { get; set; } | |
[Required] | |
[Column(TypeName = "tinyint")] | |
public State State { get; set; } | |
} | |
public static class Program | |
{ | |
public static void Main() | |
{ | |
var dbContext = new ReproDbContext(); | |
dbContext.Database.EnsureDeleted(); | |
dbContext.Database.EnsureCreated(); | |
dbContext.Models.Add(new Model()); | |
dbContext.SaveChanges(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment