CodecoolGlobal / saint-sender-csharp-cemel

saint-sender-csharp-cemel created by GitHub Classroom
0 stars 1 forks source link

Cannot migrate in EF Core #1

Open alexseres opened 3 years ago

alexseres commented 3 years ago

Have a problem to connect Postgresql database with my app, the application uses .NET and the ef core is using 3.1.11 extensions/tools. I have tried with IdesignTimeDbCOntextFactoryval as well, without successs. So the bug occurs when I tried to migrate in ef core. It says "unable to create an object of type 'AppDbContext'. For different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728". I think I got the right connection string, the database is set up, just cant do code-first approach. I have no idea where the problem is.

ngAtesz commented 3 years ago

One important thing: DO NOT MIX .net framework and core libraries because it will totally mess up your packages. If you need to share code between .net framework and core you should target .NET Standard.

Anyway in case your EF and persistent related classes, models and logic is separated into another project, like in your case it is in the SaintSender.Core. So in this case you need to put the db related configuration into your Startup project config instead of the class library. See https://stackoverflow.com/a/25406166