You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppDbContext.cs 874 B

6 years ago
6 years ago
6 years ago
6 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. using Microsoft.EntityFrameworkCore;
  2. namespace Sample.RabbitMQ.MySql
  3. {
  4. public class Person
  5. {
  6. public int Id { get; set; }
  7. public string Name { get; set; }
  8. public override string ToString()
  9. {
  10. return $"Name:{Name}, Id:{Id}";
  11. }
  12. }
  13. public class Person2
  14. {
  15. public int Id { get; set; }
  16. public string Name { get; set; }
  17. public override string ToString()
  18. {
  19. return $"Name:{Name}, Id:{Id}";
  20. }
  21. }
  22. public class AppDbContext : DbContext
  23. {
  24. public const string ConnectionString = "";
  25. public DbSet<Person> Persons { get; set; }
  26. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  27. {
  28. optionsBuilder.UseMySql(ConnectionString, ServerVersion.FromString("mysql"));
  29. }
  30. }
  31. }