-
-
Save dcomartin/baec2f857cea7850422825b66a35e355 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
public class TestDbContext : DbContext | |
{ | |
public DbSet<Order> Orders => Set<Order>(); | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ | |
var connectionString = "Server=localhost;Port=3307;Database=Demo;Uid=root;Pwd=root"; | |
optionsBuilder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); | |
optionsBuilder.LogTo(Console.WriteLine); | |
} | |
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Entity<Order>().HasKey(x => x.OrderId); | |
} | |
} | |
public class Order | |
{ | |
[Key] | |
public int OrderId { get; set; } | |
public DateTime Date { get; set; } | |
public int CustomerId { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment