JonPSmith / EfCore.TestSupport

Tools for helping in unit testing applications that use Entity Framework Core
https://www.thereformedprogrammer.net/new-features-for-unit-testing-your-entity-framework-core-5-code/
Other
352 stars 53 forks source link

Only Supports Sqlite and SQL Server #40

Closed pha3z closed 3 years ago

pha3z commented 3 years ago

Can the readme and wiki be updated to have obvious upfront statements about supported databases somewhere?

I completely failed to check supported providers. I was totally excited to use this until I got the lovely "This is not a database provider that we currently support." ::SAD_FACE::

Is the level of effort required to support other providers such as Postgres too steep?

JonPSmith commented 3 years ago

Hi @pha3z,

You must be referring to CompareEfSql and it does support other database providers (I will change the message to say that).

To make it work with another database provider you need to use the version which takes in the IDesignTimeServices for the database provider you need, e.g. comparer.CompareEfWithDb<SqlServerDesignTimeServices>(context); as shown in this section of the docs.

I'm going to leave this open to remind me to change the error message.

pha3z commented 3 years ago

Firstly, AWESOME! I'm so happy to hear I can use this with Postgres. :) Thank you! I'm super excited to use this library!

Secondly, I read that section of the doc, and I get it now. I always forget how crucial it is to recognize that there are different providers for a lot of databases.

Thirdly, I had never even heard of the "DesignTimeServices" stuff until now. I read these docs and found them unhelpful: https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/services and here https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.design.idesigntimeservices?view=efcore-3.1

Can you provide more guidance on how to make this work?

UPDATE: Nevermind. I was really overthinking it. I didn't realize I literally just plugin the magic interface for my provider in that one-liner. I got it to work.

It still saddens me that the MSDN documentation leaves me feeling pretty in the dark.

JonPSmith commented 3 years ago

Glad that it worked.

BTW The "DesignTimeServices" are needed in some cases where you need a DbContext to create a migration - see this page in the EF Core docs.

All the best with your project.

JonPSmith commented 3 years ago

Hi @pha3z,

Just to say I have split the EfSchemaCompare out into its own project and added a lots of features/fixes, especially around EF Core 5 new features.

I have also updated the exception message to list what you need to do for database providers that aren't built into the library.