Open Chicagoan2016 opened 4 years ago
I'm not sure what's the difference between local Dataportal in the one in the cloud. Both of them connect to SQL DB (local or cloud) using some config files.
If you are using EntityFramework for ORM and want to connect to your DB using appsettings.json then your need to change:
In EF Dbcontext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile("appsettings.json")
.Build();
optionsBuilder.UseSqlServer(configuration.GetConnectionString("connstring"));
}
In Dataportal, Startup.cs in "public void ConfigureServices(IServiceCollection services)"
services.AddDbContext<Dbcontext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("connstring"),
sqlServerOptions => sqlServerOptions.CommandTimeout(600)));
Add appsettings.json, add the connection:
{
"ConnectionStrings": {
"connstring": "Server=192.168.1.1;Initial Catalog=DataBaseName;Persist Security Info=False;User ID=sa;Password=ChangeMyPassword;MultipleActiveResultSets=False;"
}
@BlagoCuljak thanks
Client-side Blazor does not have any way to talk directly to a database. afaik System.Data, entity framework, etc. are not available in the browser.
Question This may be a very simple question : ) but how do we connect to a on-premise sql instance? I am used to using connection strings from configuration files. We are also going to use the default 'local' data portal so no application server. Kind Regards
Version and Platform CSLA version: 5.xx OS: Windows Platform: Blazor