RickStrahl / Westwind.Globalization

Database driven resource localization for .NET applications
544 stars 135 forks source link

SQLite/SQL Compact Edition #99

Closed s0rc3contr0l closed 6 years ago

s0rc3contr0l commented 6 years ago

Rick and Team,

First of all, I think this is a great project. Thank you so much for making it exist.

I'm having trouble getting the .NET core 2 version implemented using SQLite or SQL Compact as a database. Been at it for about 12-16 hours. I have downloaded your source code, added the projects as references in a blank default Core 2 MVC web application. I absolutely cannot get either SQLite or SQL CE databases to be read. Every time it tries to open the database I get an error back about it not being able to find the SQL server ":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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

I have tried all of the examples for setting the connection string in the code, appsettings.json and DbResourceConfiguration.json but I just cannot get it to work. I have attached my startup.cs and the data directory that is in the root of the project: Source.zip

I would be extremely grateful for any insight you could provide.

Thanks!

Mike

RickStrahl commented 6 years ago

At the moment I've only tested .NET Core with full SQL server. It should work with the other providers as well but you have to make sure that you switch provider and get the connection string right. Based on the errror message it sounds like you are still trying to connect to SQL server.

I'll try to take a look later today, but I'm travelling so my time will on this will be scarce for the next week and a half or so.

s0rc3contr0l commented 6 years ago

Rick,

Thanks for responding so quickly. I REALLY appreciate it.

Yeah, that is what I thought based on the error message.. I have definitely switched the database type and have drilled down through my code and your code and it looks like the objects have instantiated the proper DbResourceDataManagerType, but then a SQLServer error is returned. I think that the abstraction layer in there is not using the proper database provider type under the hood.

For my purposes, I'm in development for awhile so I will stick to SQLserver until you have had a chance to take a look.

Thank you very much for your contributions to the world over the years.

Enjoy your travels!

Best,

Mike

RickStrahl commented 6 years ago

Actually looking at the code I realize now that right now other provider support is broken for both .NET full and Core. The problem is that no matter what the Sql provider is used right now because the logic to check the provider is not there right now.

The reason is that Core doesn't support DbProviderFactory so there's no way to create an instance of a DbProvider without explicitly referencing the SQL libraries. We can't add the dependencies to the main DLL.

This is something I need to look at - I basically have to create a generic way to instantiate the providers without incurring the dependency - probably using Reflection to instantiate and hardcoding the provider into the specific DbResourceManager. Looking into it now, but it'll probably be next week before I get to it as I'm on the road.

s0rc3contr0l commented 6 years ago

Rick,

Thanks very much!

Cheers,

Mike

RickStrahl commented 6 years ago

I've hooked up SqLite support and it should work for most things. To do this you need some manual confguration:

services.AddWestwindGlobalization(opt =>
{
       // Resource Mode - Resx or DbResourceManager                
    opt.ResourceAccessMode = ResourceAccessMode.DbResourceManager;  // ResourceAccessMode.Resx

    // SqLite
    opt.ConnectionString = "Data Source=./Data/SqLiteLocalizations.db";
    opt.DbResourceDataManagerType = typeof(DbResourceSqLiteDataManager);

    opt.ResourceTableName = "localizations";
});

There's no Sql Compact support in .NET Core from Microsoft or other providers so that's a non-starter unfortunately.

s0rc3contr0l commented 6 years ago

Rick,

Thank you very much. I really appreciate it.

I will test this out next week and confirm that it’s working on my end.

Best,

Mike

From: Rick Strahl [mailto:notifications@github.com] Sent: Friday, November 10, 2017 2:10 AM To: RickStrahl/Westwind.Globalization Westwind.Globalization@noreply.github.com Cc: Ferrel, Michael mferrel@orrick.com; Author author@noreply.github.com Subject: Re: [RickStrahl/Westwind.Globalization] SQLite/SQL Compact Edition (#99)

I've hooked up SqLite support and it should work for most things. To do this you need some manual confguration:

services.AddWestwindGlobalization(opt =>

{

   // Resource Mode - Resx or DbResourceManager

opt.ResourceAccessMode = ResourceAccessMode.DbResourceManager;  // ResourceAccessMode.Resx

// SqLite

opt.ConnectionString = "Data Source=./Data/SqLiteLocalizations.db";

opt.DbResourceDataManagerType = typeof(DbResourceSqLiteDataManager);

opt.ResourceTableName = "localizations";

});

All operations work but there appear to be some provider problems in .NET Core as the database gets locked and doesn't unlock. I'm still looking at this now, but if you want to look at this this is a place to start.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/RickStrahl/Westwind.Globalization/issues/99#issuecomment-343432366, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AfC6Q2mz07eu-EEydHO7skAwJguuSUA_ks5s1CENgaJpZM4QGrvj.

NOTICE TO RECIPIENT | This e-mail is meant for only the intended recipient of the transmission, and may be a communication privileged by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of this e-mail is strictly prohibited. Please notify us immediately of the error by return e-mail and please delete this message from your system. Thank you in advance for your cooperation.

For more information about Orrick, please visit http://www.orrick.comhttp://www.orrick.com/.

RickStrahl commented 6 years ago

Beta 1 is now out and things should defintely work with SQLite now.

s0rc3contr0l commented 6 years ago

Rick,

Thanks a lot. Seems like things are working. I reallly appreciate it.

Best,

Mike

On Wed, 2017-12-06 at 06:46 +0000, Rick Strahl wrote:

Closed #99https://github.com/RickStrahl/Westwind.Globalization/issues/99.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/RickStrahl/Westwind.Globalization/issues/99#event-1374185624, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AfC6QxMJssHOh2NfGjtDRJfYKQsFv78Kks5s9jhfgaJpZM4QGrvj.

NOTICE TO RECIPIENT | This e-mail is meant for only the intended recipient of the transmission, and may be a communication privileged by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of this e-mail is strictly prohibited. Please notify us immediately of the error by return e-mail and please delete this message from your system. Thank you in advance for your cooperation.

For more information about Orrick, please visit http://www.orrick.comhttp://www.orrick.com/.