-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6238c4d
commit 5a3c371
Showing
10 changed files
with
93 additions
and
7 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
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,43 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Configuration; | ||
using System.Data.Common; | ||
using System.Data.Entity; | ||
using Sentry; | ||
using Sentry.EntityFramework; | ||
|
||
// Add this as early as possible to collect breadcrumbs: | ||
SentryDatabaseLogging.UseBreadcrumbs(); | ||
|
||
var _ = SentrySdk.Init(o => | ||
{ | ||
o.Debug = true; // To see SDK logs on the console | ||
o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537"; | ||
// Add the EntityFramework integration to the SentryOptions of your app startup code: | ||
o.AddEntityFramework(); | ||
}); | ||
|
||
var dbConnection = Effort.DbConnectionFactory.CreateTransient(); | ||
using var db = new SampleDbContext(dbConnection, true); | ||
|
||
var user = new SampleUser(); | ||
db.Users.Add(user); | ||
|
||
// This will throw a DbEntityValidationException and crash the app | ||
// But Sentry will capture the error. | ||
db.SaveChanges(); | ||
|
||
public class SampleUser | ||
{ | ||
[Key] | ||
public int Id { get; set; } | ||
[Required] | ||
public string RequiredColumn { get; set; } | ||
} | ||
|
||
public class SampleDbContext : DbContext | ||
{ | ||
public DbSet<SampleUser> Users { get; set; } | ||
public SampleDbContext(DbConnection connection, bool ownsConnection) | ||
: base(connection, ownsConnection) | ||
{ } | ||
} |
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,10 @@ | ||
# Entity Framework 6 sample | ||
|
||
If you're using Entity Framework Core, you don't need the package used in this sample. | ||
Sentry can integrate with EF Core through `Sentry.Extensions.Logging` already. | ||
Sentry.EntityFramework` is used to integrated with EF 6 only. | ||
|
||
![Crash in Sentry](crash.png) | ||
|
||
Breadcrumbs for different EF core events: | ||
![Example in Sentry](ef.png) |
14 changes: 14 additions & 0 deletions
14
samples/Sentry.Samples.EntityFramework/Sentry.Samples.EntityFramework.csproj
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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Effort.EF6" Version="2.2.13" /> | ||
<ProjectReference Include="../../src/Sentry.EntityFramework/Sentry.EntityFramework.csproj" /> | ||
<ProjectReference Include="../../src/Sentry/Sentry.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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
9 changes: 7 additions & 2 deletions
9
test/Sentry.EntityFramework.Tests/Sentry.EntityFramework.Tests.csproj
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