haider_kazal
haider_kazal

Reputation: 3468

ORM without database foreign key

I have an old database, where tables have no primary-foreign key relation. And I can't change/add relations in the database now.

I'm trying to use Entity Framework or an ORM tool. Please tell me if it is possible to use any ORM in this kind of situation? If not, what will be appropriate way to design my DAL?

I'm using ASP.NET Web API.

Upvotes: 2

Views: 641

Answers (2)

marc_s
marc_s

Reputation: 754488

Have a look at Dapper.NET

Since it just basically "hydrates" whatever an arbitrary SQL statement returns, it'll be able to handle even such a crappy database design - as long as you can express your query in T-SQL, Dapper can build you some nice .NET objects for it.

Dapper is also the lightweight ORM used by Stackoverflow itself :-)

Upvotes: 2

Jamie Humphries
Jamie Humphries

Reputation: 3688

As long as your database tables have primary keys, you will be able to use Entity Framework for the basics like mapping your table rows to C# objects and doing LINQ-to-Entity queries.

However without foreign keys, you won't be able to take advantage of navigation properties. This will mean that a number of things will be more manual and long-winded than if you had proper foreign keys but you should still be able to do any data manipulation that you want.

Upvotes: 0

Related Questions