Introduction
In C#, a model usually refers to a strongly typed class that represents structured data (for example, a DTO, entity, or domain object). However, there are many scenarios where you may want to create objects without defining a formal model class:
Rapid prototyping
Handling dynamic or unknown data shapes (JSON, configuration, metadata)
Reducing boilerplate for small or temporary data structures
Interacting with dynamic APIs
This article explains the best technical approaches to creating objects without a model in C#, with examples, pros, cons, and guidance on when to use each approach.
1. Anonymous Types (Best for Local, Read-Only Data)
Overview
Anonymous types allow you to create an object without defining a class, directly inline in your code. The compiler generates a temporary type for you.
Example
var user = new
{
Id = 1,
Name = "Alice",
IsActive = true
};
Console.WriteLine(user.Name);
Characteristics
Properties are read-only
Type is known only at compile time
Scope is limited (method-level usage)
Pros
Very concise and readable
Strongly typed (compile-time safety)
No class definition required
Cons
Cannot return from public methods easily
Cannot modify properties
Not suitable for complex logic or reuse
Best Use Cases
LINQ projections
Temporary data grouping
Local calculations
2. dynamic Objects (Best for Runtime Flexibility)
Overview
The dynamic keyword defers type checking to runtime, allowing you to add or change properties dynamically.
Example
dynamic user = new ExpandoObject();
user.Id = 1;
user.Name = "Bob";
user.IsActive = true;
Console.WriteLine(user.Name);
Required Namespace
using System.Dynamic;
Pros
Extremely flexible
Properties can be added/removed at runtime
Ideal for JSON or loosely typed data
Cons
No compile-time safety
Runtime errors possible
Slower performance than strongly typed objects
Best Use Cases
Consuming dynamic APIs
JSON parsing without schemas
Plugin or scripting systems
3. Dictionary<string, object> (Best for Data-Driven Scenarios)
Overview
Using a dictionary allows you to store key-value pairs where values can be of any type.
Example
var user = new Dictionary<string, object>
{
{ "Id", 1 },
{ "Name", "Charlie" },
{ "IsActive", true }
};
Console.WriteLine(user["Name"]);
Pros
Simple and explicit
Fully dynamic structure
Easy to serialize/deserialize
Cons
No IntelliSense support
Manual casting required
Error-prone for large datasets
Best Use Cases
Metadata storage
Configuration systems
Key-value based processing
4. Tuples (Best for Small, Structured Data)
Overview
Tuples provide a lightweight way to group multiple values without a model class.
Example
var user = (Id: 1, Name: "Diana", IsActive: true);
Console.WriteLine(user.Name);
Pros
Lightweight and fast
Named fields improve readability
Compile-time type safety
Cons
Not expressive for complex domains
Limited scalability
Not suitable for APIs or persistence
Best Use Cases
Returning multiple values from a method
Small data transfers
Performance-sensitive code
5. JSON-Based Objects (JsonElement / JObject)
Overview
When working with JSON-heavy systems, you can manipulate objects without defining models using JSON APIs.

Join the conversation! Your thoughts help the community grow.