-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from isaacgimenez/feature/exclude-property-att…
…ribute Added option to exclude properties through attribute
- Loading branch information
Showing
17 changed files
with
446 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
.../AspNetCore5.0.MVC.EF.Blogs/Migrations/20210705113831_blog_privateURLProperty.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
samples/AspNetCore5.0.MVC.EF.Blogs/Migrations/20210705113831_blog_privateURLProperty.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace EFGetStarted.AspNetCore.NewDb.Migrations | ||
{ | ||
public partial class blog_privateURLProperty : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AddColumn<string>( | ||
name: "PrivateURL", | ||
table: "Blogs", | ||
type: "nvarchar(max)", | ||
nullable: true); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropColumn( | ||
name: "PrivateURL", | ||
table: "Blogs"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
samples/AspNetCore5.0.MVC.EF.Blogs/Models/ContextFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Design; | ||
|
||
namespace EFGetStarted.AspNetCore.NewDb.Models | ||
{ | ||
/// <summary> | ||
/// Class need for EF Migrations to know how the Context should be created. | ||
/// This class is not intended for use on the applications. | ||
/// </summary> | ||
public class BloggingContextFactory : IDesignTimeDbContextFactory<BloggingContext> | ||
{ | ||
/// <summary> | ||
/// Creates a DbOptionsBuilder from a connectionString. | ||
/// </summary> | ||
/// <param name="connectionString">ConnectionString to apply.</param> | ||
/// <returns>DbContextOptionsBuilder.</returns> | ||
public static DbContextOptionsBuilder CreateDbOptionsBuilder(string connectionString) | ||
{ | ||
var options = new DbContextOptionsBuilder(); | ||
return SetDbOptions(options, connectionString); | ||
} | ||
|
||
/// <summary> | ||
/// Set options to a DbOptionsBuilder. | ||
/// </summary> | ||
/// <param name="options">Options.</param> | ||
/// <param name="connectionString">ConnectionString to apply.</param> | ||
/// <returns>DbContextOptionsBuilder.</returns> | ||
public static DbContextOptionsBuilder SetDbOptions(DbContextOptionsBuilder options, string connectionString) | ||
{ | ||
return options.UseSqlServer(connectionString); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Create a new DB Context, not intended to be used. | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public BloggingContext CreateDbContext(string[] args) | ||
{ | ||
var connection = @"Server=.;Database=AutoHistoryTest;Trusted_Connection=True;ConnectRetryCount=0"; | ||
var optionsBuilder = CreateDbOptionsBuilder(connection); | ||
return new BloggingContext(optionsBuilder.Options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.