Database creates (entity framework)
This commit is contained in:
39
ASP.Net Core/MVCBasics/Data/ApplicationDBContext.cs
Normal file
39
ASP.Net Core/MVCBasics/Data/ApplicationDBContext.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EntityFrameworkBasics
|
||||
{
|
||||
/// <summary>
|
||||
/// The database representational model for application
|
||||
/// </summary>
|
||||
public class ApplicationDBContext : DbContext
|
||||
{
|
||||
#region Public properties
|
||||
|
||||
public DbSet<SettingsDataModel> Settings { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public ApplicationDBContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
// tfoUbuntu;User ID=sa;Password=********;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
|
||||
//optionsBuilder.UseSqlServer("Server=192.168.0.135;Database=entityframework;")
|
||||
optionsBuilder.UseSqlServer("Server=192.168.0.135;Database=entityframework;User ID=sa;Password=SAtfoubuntu1SA;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;MultipleActiveResultSets=true;");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
21
ASP.Net Core/MVCBasics/Data/SettingsDataModel.cs
Normal file
21
ASP.Net Core/MVCBasics/Data/SettingsDataModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace EntityFrameworkBasics
|
||||
{
|
||||
/// <summary>
|
||||
/// Our Settings database table representional model
|
||||
/// </summary>
|
||||
public class SettingsDataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The unique Id for this entry
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// The settings name
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// The settings value
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user