本文整理汇总了C#中DbContextOptionsBuilder.UseSqlServer方法的典型用法代码示例。如果您正苦于以下问题:C# DbContextOptionsBuilder.UseSqlServer方法的具体用法?C# DbContextOptionsBuilder.UseSqlServer怎么用?C# DbContextOptionsBuilder.UseSqlServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbContextOptionsBuilder
的用法示例。
在下文中一共展示了DbContextOptionsBuilder.UseSqlServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// Use the provider Connection to Create the Context
if(m_connection != null)
{
optionsBuilder.UseSqlServer(m_connection);
}
else
{
m_connection = CreateConnection();
optionsBuilder.UseSqlServer(m_connection);
}
base.OnConfiguring(optionsBuilder);
}
示例2: OnConfiguring
//Add-Migration lmcom-serv-001 -c NewData.NewLMComContext_SqlServer
//Update-Database lmcom-serv-002 -c NewData.NewLMComContext_SqlServer
protected override void OnConfiguring(DbContextOptionsBuilder options) {
base.OnConfiguring(options);
var config = ConfigurationManager.ConnectionStrings["Container"];
var conn = new SqlConnection(config.ConnectionString);
//var conn = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=NewLMCom_ef7;Integrated Security=False;User ID=lmcomdatatest;Password=lmcomdatatest;");
options.UseSqlServer(conn);
}
示例3: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// TODO GitHubIssue#57: Complete EF7 to EDM model mapping
// Seems for now EF7 can't support named connection string like "name=NorthwindConnection",
// find an equivalent approach when it's ready.
optionsBuilder.UseSqlServer(@"data source=(localdb)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\Northwind.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework");
base.OnConfiguring(optionsBuilder);
}
示例4: Is_configured_when_configuration_contains_associated_extension
public void Is_configured_when_configuration_contains_associated_extension()
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer("Database=Crunchie");
Assert.True(new DatabaseProvider<SqlServerDatabaseProviderServices, SqlServerOptionsExtension>().IsConfigured(optionsBuilder.Options));
}
示例5: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var ConnectionString = Startup.Configuration["Data:DefaultConnection:ConnectionString"];
optionsBuilder.UseSqlServer(ConnectionString);
base.OnConfiguring(optionsBuilder);
}
示例6: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=SpyStoreData;Trusted_Connection=True;MultipleActiveResultSets=true;");
}
}
示例7: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
#if DEBUG
ConnectionString = "Server=(localdb)\\MSSQLLocalDB;Database=Health;Trusted_Connection=True;";
#endif
optionsBuilder.UseSqlServer(ConnectionString);
}
示例8: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
//var connectionString = @"Data Source=SERENITY\EXPRESS2014;Initial Catalog=TicketSystem;Integrated Security=True";
var connectionString = @"Data Source=ENTERPRISE1\EXPRESS2014;Initial Catalog=code_louisville_dotnet;Integrated Security=True";
optionsBuilder.UseSqlServer(connectionString);
}
示例9: CreateOptions
public static IDbContextOptions CreateOptions()
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Database=SqlServerConnectionTest");
return optionsBuilder.Options;
}
示例10: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Demo.ReplacingServices;Trusted_Connection=True;");
// TODO Register our custom type mapper
}
示例11: OnConfiguring
// Estabelecendo conexão com o banco.
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string stringConexao = ConfigurationManager.ConnectionStrings["EstudosEntityConnectionString"].ConnectionString;
optionsBuilder.UseSqlServer(stringConexao);
base.OnConfiguring(optionsBuilder);
}
示例12: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
var config = new Configuration()
.AddJsonFile("config.json");
var constr = config.Get("Data:DefaultConnection:ConnectionString");
options.UseSqlServer(constr);
}
示例13: Is_configured_when_configuration_contains_associated_extension
public void Is_configured_when_configuration_contains_associated_extension()
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer("Database=Crunchie");
Assert.True(new SqlServerDataStoreSource().IsConfigured(optionsBuilder.Options));
}
示例14: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var connString = Startup.Configuration["Data:WorldContextConnection"];
optionsBuilder.UseSqlServer(connString);
base.OnConfiguring(optionsBuilder);
}
示例15: OnConfiguring
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!string.IsNullOrEmpty(ConnectionString))
{
optionsBuilder.UseSqlServer(ConnectionString);
}
}