25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppDbContext.cs 905 B

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 = "Server=192.168.2.120;Database=captest;UserId=root;Password=123123;";
  25. public DbSet<Person> Persons { get; set; }
  26. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  27. {
  28. optionsBuilder.UseMySql(ConnectionString);
  29. }
  30. }
  31. }