𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓
𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 2/23/2024 in #help
Trying to scaffold a controller for ASP .NET api using MongoDB but get this message
The problem was solved by switching from EFCore to a standalone IMongoDB. EFCore does not seem to have stable support for MongoDB at this time.
5 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 2/23/2024 in #help
Trying to scaffold a controller for ASP .NET api using MongoDB but get this message
I managed to scaffold the controller by bypassing the mongoDB registration to the apps builderServices using temporary InMemory db. However I am now faced with another issue. Since the mongo database won't register to the app, the endpoints do not show up in the Swagger UI. What are my options from here? This is what the context looks like.
internal class PostContext : DbContext
{
public DbSet<PostModel> Posts { get; init; }

private const string connectionString = "mongodb://localhost:27017";

public PostContext(DbContextOptions<PostContext> options) : base(options)
{
}

public static PostContext Create(IMongoDatabase database) =>
new(new DbContextOptionsBuilder<PostContext>()
.UseMongoDB(database.Client, database.DatabaseNamespace.DatabaseName)
.Options);


protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var client = new MongoClient(connectionString);

optionsBuilder.UseMongoDB(client, "WebCollection"); // This row does not seem to work
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<PostModel>().ToCollection("posts");
}

}
internal class PostContext : DbContext
{
public DbSet<PostModel> Posts { get; init; }

private const string connectionString = "mongodb://localhost:27017";

public PostContext(DbContextOptions<PostContext> options) : base(options)
{
}

public static PostContext Create(IMongoDatabase database) =>
new(new DbContextOptionsBuilder<PostContext>()
.UseMongoDB(database.Client, database.DatabaseNamespace.DatabaseName)
.Options);


protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var client = new MongoClient(connectionString);

optionsBuilder.UseMongoDB(client, "WebCollection"); // This row does not seem to work
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<PostModel>().ToCollection("posts");
}

}
5 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 2/23/2024 in #help
Trying to scaffold a controller for ASP .NET api using MongoDB but get this message
Thanks, I'll try this!
5 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Yup
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Thanks ^^
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Yeah I'll try that
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
ait then i will look into this :)
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
The get method should then get that data and return it to the game
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
The WebApi parts job is to take the data sent from the reactiongame and store it into a SQLite database
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
That is what i am attempting using the post and get endpoints
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
No it is just supposed to store data
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Im sending the data from my game to a web api then using the get method to retrieve it from the site
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
["{\"Name\":\"Pet\",\"Time\":316}","{\"Name\":\"Pet\",\"Time\":278}"]
["{\"Name\":\"Pet\",\"Time\":316}","{\"Name\":\"Pet\",\"Time\":278}"]
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Seems the json string has been altered somehow
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Might have found it
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Hm
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
thanks anyways :)
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
Bruh 😓
40 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 3/1/2023 in #help
Newtonsoft.Json Serialization Exception
What did you change exactly?
40 replies