EF Poco Create for a specific table
You can create a class POCO
for one selected table in the entity structure.
There are several tools that do this, but they generate for the whole table,
The main reason I am asking is to create a class POCO
for a separate table and add attributes to it manually and all I have to do is attach it to DbContext
as a property :).
Like for example with Package-manager they do it to add migration
generate-poco TableName FileName.cs
source to share
You can use the ADO.Net wizard to generate POCO classes for you from the database. The wizard will generate one incomplete class for the table with properties matching your field names. This is what I have done in the past when I wanted to add a new large table to an existing code context.
- Add-> New Item -> ADO.Net Entity Data Model
- Move the generated POCO classes to a different folder (and edit the namespace)
- Remove the rest of the extra stuff (Ieedmx file and generated context)
- Add DBSet to 'your' DBContext
If you are using EF migrations
- add-in migration
- updating the database,
source to share