I have to use for the first time the LinqToDB library, so I'm reading their step by step:
https://linq2db.github.io/articles/get-started/full-dotnet/existing-db.html
Which basically is:
1-Create a new Project (Done, console one )
2-Install the LinqToDB packages (Done, linq2db.SqlServer installed)
3-Generate model from database ( Done, with .tt file)
4-Use my model...
Here starts the problem, firstly you have to add a .config file, my entire file looks like this:
<configuration>
<connectionStrings>
<add name="MyDatabase" providerName="System.Data.SqlClient"
connectionString="Server=DESKTOP-HMRUEF4\SQLSERVER;Database=CrudWF;Trusted_Connection=True;" />
</connectionStrings>
I just changed the connectionString to my local database string
Then it's already supposed to work in the main method ...
static void Main(string[] args)
{
using (var database = new DataModels.CrudWFDB())
{
var q = from student in database.Alunos
select student;
foreach (var student in q)
Console.WriteLine(student.Nome);
}
}
The Problem:
When I run the app, in the line where new DataModels.CrudWFDB()
is called it throws an exception:
LinqToDB.LinqToDBException: 'Configuration string is not provided.'
I didn't edit the autogenerated model class because I think the problem isn't there, but here is the constructor for CrudWFDB()
:
public CrudWFDB()
{
InitDataContext();
InitMappingSchema();
}
I'm stuck on this part, what can I do?