当前位置: 首页>>代码示例>>C#>>正文


C# DbContextOptionsBuilder.UseSqlServer方法代码示例

本文整理汇总了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);
        }
开发者ID:jcanady20,项目名称:EF7_Sample,代码行数:15,代码来源:SqlContext.cs

示例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);
 }
开发者ID:PavelPZ,项目名称:NetNew,代码行数:9,代码来源:NewLMComContext.cs

示例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);
        }
开发者ID:adestis-mh,项目名称:RESTier,代码行数:9,代码来源:NorthwindContext.cs

示例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));
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:7,代码来源:SqlServerDatabaseSourceTest.cs

示例5: OnConfiguring

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var ConnectionString = Startup.Configuration["Data:DefaultConnection:ConnectionString"];
            optionsBuilder.UseSqlServer(ConnectionString);

            base.OnConfiguring(optionsBuilder);
        }
开发者ID:usmslm102,项目名称:Aspnet5Crud,代码行数:7,代码来源:CustomerContext.cs

示例6: OnConfiguring

 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     if (!optionsBuilder.IsConfigured)
     {
         optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=SpyStoreData;Trusted_Connection=True;MultipleActiveResultSets=true;");
     }
 }
开发者ID:techoli76,项目名称:KCDC_ASPDOTNET,代码行数:7,代码来源:SpyStoreContext.cs

示例7: OnConfiguring

 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     #if DEBUG
     ConnectionString = "Server=(localdb)\\MSSQLLocalDB;Database=Health;Trusted_Connection=True;";
     #endif
     optionsBuilder.UseSqlServer(ConnectionString);
 }
开发者ID:Sharpiro,项目名称:Health,代码行数:7,代码来源:HealthContext.cs

示例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);
 }
开发者ID:garrettld,项目名称:code_louisville_dotnet,代码行数:7,代码来源:TicketsDataContext.cs

示例9: CreateOptions

        public static IDbContextOptions CreateOptions()
        {
            var optionsBuilder = new DbContextOptionsBuilder();
            optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Database=SqlServerConnectionTest");

            return optionsBuilder.Options;
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:7,代码来源:SqlServerConnectionTest.cs

示例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

        }
开发者ID:rowanmiller,项目名称:Demo-EFCore,代码行数:7,代码来源:Program.cs

示例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);
        }
开发者ID:ClairtonLopesJr,项目名称:LABS,代码行数:8,代码来源:EntidadesContext.cs

示例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);
 }
开发者ID:LeoLcy,项目名称:MVC6Recipes,代码行数:7,代码来源:ArtistContext.cs

示例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));
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:7,代码来源:SqlServerDataStoreSourceTest.cs

示例14: OnConfiguring

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var connString = Startup.Configuration["Data:WorldContextConnection"];
            optionsBuilder.UseSqlServer(connString);

            base.OnConfiguring(optionsBuilder);
        }
开发者ID:danielmackay,项目名称:ASP-NET-5,代码行数:7,代码来源:WorldContext.cs

示例15: OnConfiguring

 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     if (!string.IsNullOrEmpty(ConnectionString))
     {
         optionsBuilder.UseSqlServer(ConnectionString);
     }
 }
开发者ID:agcavaleiro,项目名称:SlnFortes,代码行数:7,代码来源:DataContext.cs


注:本文中的DbContextOptionsBuilder.UseSqlServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。