How to connect configure Entity Framework to connect to SQL Server?

.net-core asp.net entity-framework-core sql-server

Question

I'm setting up the SQL Server connection for Entity Framework Core having two more systems and connection via LAN, SQL installed in only one system? So, let me know how to connect DB for another system. Below see my code...

First code:

services.AddEntityFrameworkSqlServer()
        .AddDbContext<CatalogDbContext>(Option=Option.UseSqlServer(@"Data Source=MACHINE-2;Initial Catalog=ShoppingCart;Integrated Security=True;Pooling=False"));     

Second Code:

services.AddEntityFrameworkSqlServer()
        .AddDbContext<CatalogDbContext>
(Option=>Option.UseSqlServer(@"Data Source=192.168.2.2;Initial Catalog=ShoppingCart;Integrated Security=True;Pooling=False"));      

first code connection successfully and second code not to connect DB?

1
0
1/31/2019 3:17:11 PM

Popular Answer

You should try creating another DbContext to connect to the other Data Source. The same way you connected to he first one will work but with a different DB Context.

0
1/31/2019 3:10:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow