Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to validate ef core model with in sql server provider in tests #52

Open
2 tasks
fb-smit opened this issue Apr 5, 2024 · 0 comments
Open
2 tasks
Labels
EFCore enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed PiBox.Testing

Comments

@fb-smit
Copy link
Contributor

fb-smit commented Apr 5, 2024

Use case:

  • DB-First
  • Model generated by dotnet ef cli tool with "scaffold"

To help with making sure the generated model is valid with the sql server provider there should be a method to help out with that.

Maybe we need a new project for sql server specific thing in testing or we would need to add the nuget package for the sql server to the general testing package (which i would not prefer).

Code could look something like this:

var builder = new DbContextOptionsBuilder<MyDbContext>();
builder.UseSqlServer("Server=.;Database=404;Connection Timeout=1;Command timeout=1");
using var ctx = new MyDbContext(builder.Options);
var action = () => ctx.AnyTable.FirstOrDefault();
action.Should().ThrowExactly<SqlException>().WithMessage(
    "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)");

This test or method would throw exceptions if the model has some issues with the sql server provider, so one can fix them right away.

  • Decide where to put this functionality for helping out with testing db models used in sql server
  • Implement and provide the functionality described
@fb-smit fb-smit added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed EFCore PiBox.Testing labels Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EFCore enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed PiBox.Testing
Projects
None yet
Development

No branches or pull requests

1 participant